SlideShare ist ein Scribd-Unternehmen logo
1 von 61
by Gururaj
Learn How To Use Selenium Successfully
In Conjunction With Other Tools
• We have INSTRUCTOR -LED - both Online LIVE & Classroom Session
 Present for classroom sessions in Bangalore & Delhi (NCR)
 We are the ONLY Education delivery partners for Mulesoft, Elastic, Pivotal & Lightbend in
India
 We have delivered more than 5000 trainings and have over 400 courses and a vast pool of
over 200 experts to make YOU the EXPERT!
 FOLLOW US ON SOCIAL MEDIA TO STAY UPDATED ON THE UPCOMING WEBINARS
Non-Certified Courses
…and many more
Certified Partners
• Selenium tool
• Write maintainable and reusable Selenium scripts
• Reporting Structure by using external plugin's
• Cross browser testing (Running selenium grid with Docker)
• UI layout test using Galen framework
• Maven– automation build tool
• Code repository (Git)
• Jenkins CI tool
Agenda
Selenium
Selenium is the best open source tool for doing automation for web based
application and it does not have any cost attached to it. The only cost is the effort which
will go for designing and developing the script for the application.
Selenium scripting can be done in a number of programming languages like C#, Perl,
PHP, Ruby, Java etc, unlike other commercial tools which support single scripting
language. Since Selenium scripting can be done in any language of choice, one can easily
find right resources for the programming language chosen for Selenium Automation.
Last but not the least, since this tool comes at ZERO PRICE, an organization’s
management will find that the only investment they have made is on the infrastructure and
human effort and not on the heavy licensing cost.
IDE WebDriver Grid
 Selenium uses what is called locators to find and match the
elements of your page that it needs to interact with:
 Link
 XPath
 ID
 Name
 CSS
Locators
Add on's
Css selector helper
WebDriver Element Locator
Page object generator - Plugin
Selenium Page Object Generator is an essential tool
to improve your workflow. It will generate Page
Object Model on active Chrome tab with a single
click, provided that all the options and template are
configured. The generated Page Object Model will
be saved to pre-configured Chrome download folder.
It strives to reduce manual involvement, but manual
tweak still recommended
Sample file
Preferred selector order to locators ;
Preferred Order
ID Locator
NAME Locator
CSS Locator
XPATH Locator
 Thread.sleep
 Implicit Waits
 Explicit Waits
 FluentWait
Implicit waits :Once set, the implicit wait is set for the life of
the WebDriver object instance.
Explicit waits: An explicit waits is code you define to wait for
a certain condition to occur before proceeding further in the
code
Exception Handling
Expected Conditions
Because it's quite a common occurrence to have to synchronize the DOM and your
instructions, most clients also come with a set of predefined expected conditions. As
might be obvious by the name, they are conditions that are predefined for frequent
wait operations.
The conditions available in the different language bindings vary, but this is a non-
exhaustive list of a few:
alert is present
element exists
element is visible
title contains
title is
visible text
Expected Conditions
Expected Conditions
Because it's quite a common occurrence to have to synchronize the DOM and your
instructions, most clients also come with a set of predefined expected conditions. As
might be obvious by the name, they are conditions that are predefined for frequent wait
operations.
The conditions available in the different language bindings vary, but this is a non-
exhaustive list of a few:
alert is present
element exists
element is visible
title contains
title is
visible text
Expected Conditions
Sample code...
Problem : open Jquery component and try to get tooltip for the
textbox
Other Options
FluentWait instance defines the maximum amount of time to wait for a condition, as
well as the frequency with which to check the condition.
User may configure the wait to ignore specific types of exceptions whilst waiting, such
as NoSuchElementExceptions when searching for an element on the page.
// Waiting 30 seconds for an element to be present on the page, checking
// for its presence once every 5 seconds.
Wait<WebDriver> wait = new FluentWait<WebDriver>(driver)
.withTimeout(30, SECONDS)
.pollingEvery(5, SECONDS)
.ignoring(NoSuchElementException.class);
WebElement foo = wait.until(new Function<WebDriver, WebElement>() {
public WebElement apply(WebDriver driver) {
return driver.findElement(By.id("foo"));
}
});
Fluent Waits
 Common functions or Keywords
 Click, Verify, Wait for Element, EnterText, SelectBox etc..
 Page Object Model / Factory
Reusability
Example
 Page Object Model is a design pattern to create Object Repository for web
 UI elements.
 Under this model, for each web page in the application there should be
corresponding page class.
 This Page class will find the WebElements of that web page and also contain page
methods which perform operations on those WebElements.
 Name of these methods should be given as per the task they are performing
Page Object Model
POM - Example
TestCases
Pages
Page Factory
Page Factory is an inbuilt page object model concept for Selenium WebDriver
@FindBy elements - use of @FindBy annotations. With this annotation, we can define a
strategy for looking up the element, along with the necessary information for identifying
it:
@FindBy can accept tagName, partialLinkText, name, linkText, id, css,
className, xpath as attributes.
Example
LoginPage = PageFactory.initElements(driver, LoginPagePOF.class);
}
@Test
public void test() {
LoginPage.LogIn_Action("guest", "guest");
System.out.println(" Login Successfully, now it is the time to Log Off buddy.");
}
Page Factory
Page Factory Class
To initialize WebElements
Page Factory - Project
Page Factory
TestNG classes
Test Data
Config
Utility Factory
Reports
Screen Shots
Logs
`
`
`
`
Generating reports is always challenge with Selenium, since it doesn't comes with
any reporting features. There are lot of plugin's available will see in action;
REPORTING
XSLT
Report NG
ATU Reports
Extent
<target name="xsltreports">
<mkdir dir="${basedir}/XSLT_Reports/output"/>
<xslt in="${ng.result}/testng-results.xml"
style="src/com/xslt/testng-results.xsl"
out="${basedir}/XSLT_Reports/output/index.html"
classpathref="classpath_jars" processor="SaxonLiaison">
<param name="testNgXslt.outputDir"
expression="${basedir}/XSLT_Reports/output/"/>
<param name="testNgXslt.showRuntimeTotals"
expression="true"/>
</xslt>
</target>
XSLT - Reporting
Create ANT task in build.xml file with target
Sample Report
ReportNG is a simple HTML reporting plug-in for the TestNGunit-testing
framework. It is intended as a replacement for the default TestNG HTML report.
The default report is comprehensive but is not so easy to understand at-a-glance.
ReportNG provides a simple, colour-coded view of the test results.
ReportNG generates 100% valid XHTML 1.0 files. The output can be customised
by over-riding the default stylesheet with your own CSS file.
ReportNG - Plugin
Sample Report
Very simple to use API
Beautiful and responsive UI
Provides dashboard for the entire run
Parallel execution of classes and methods supported
Creates a single report file, so less management of artifacts required (Online only*,
Offline
report stores all artifacts locally)
Separate section for categories, provides analysis of tests by category
Easily integrate test-runner logs
Can be customized heavily using an external config file
and this is developed by http://extentreports.relevantcodes.com
Extent Reports - Plugin
Very simple to use API
Beautiful and responsive UI
Provides dashboard for the entire run
Parallel execution of classes and methods supported
Creates a single report file, so less management of artifacts required (Online only*, Offline
report stores all artifacts locally)
Separate section for categories, provides analysis of tests by category
Easily integrate test-runner logs
Can be customized heavily using an external config file
and this is developed by http://extentreports.relevantcodes.com
Extent Reports - Plugin
Sample Report
ATU Reporter is free open source plugin/utility for Selenium. This will be a TestNG
listener for generating customized graphical reports. Following reports can be
generated by this listener.
Line Charts
Bar Charts
Pie Charts
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite" parallel="false">
<test name="Test">
<classes>
<class name="com.test.AUTReporting.ReporterGoogleTest"/>
</classes>
</test>
<listeners>
<listener class-name="atu.testng.reports.listeners.ATUReportsListener"></listener>
<listener class-name="atu.testng.reports.listeners.ConfigurationListener"></listener>
<listener class-name="atu.testng.reports.listeners.MethodListener"></listener>
</listeners>
</suite>
ATU Reports - Plugin
Sample Report
Cross Browser Testing is a type of functional test to check that your web application
works as expected in different browsers.
Cross Browser Testing
CBT – With cloud
services
Running test on local machine with different OS with different combination of
browsers its always a challenge, either we need to get more machine and really on
selenium grid to solve the problem. Now without installing any OS or browser can we
run the selenium scripts on cloud, yes its possible with some of the cloud services like
Testing bot
Sauce lab
BrowserSTack.
public static final String KEY = "your key paste here";
public static final String SECRET = "your secret paste here";
public static final String URL = "http://" + KEY + ":" + SECRET + "@hub.testingbot.com/wd/hub";
public static void main(String[] args) throws IOException, InterruptedException {
// TODO Auto-generated method stub
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability("platform", "WIN8");
caps.setCapability("version", "35");
caps.setCapability("browserName", "chrome");
// Remote web driver to register with testing bot key and secret, so that it will launch browser on these machines
driver = new RemoteWebDriver(new URL(URL), caps);
driver.get("https://timetracker.anuko.com/login.php");
Grid with Cloud Services
 In simple words, Docker – with use of linux-containers – allows you to
pack all your application dependencies, like database, system libraries
and so on, into standardized and portable units, called containers.
 You don’t need to ship entire OS to your CI or production server.
 We can manage this with containers with independent units.
Selenium Grid with Docker
Docker is a lightweight container (read: a scaled-down VM) that provides a fast and programmatic
way to run distributed applications. Selenium Grid is distributed system of nodes for running tests.
Instead of running your grid across multiple machines or VMs, you can run them all on a single
large machine using Docker.
`docker-selenium` project is about packaging selenium grid as docker containers
(https://github.com/seleniumhq/docker-selenium)
We don't have to build any selenium infrastructure machines. I just run the provided images by
docker-selenium project (https://hub.docker.com/r/selenium/).
We don't have to install selenium jar, java, browsers and other runtime dependencies. They are
already built in a docker image and I can just run them as either selenium grid with hub and nodes
or as standalone selenium on any docker engine enabled vm.
Docker
Setup
Create Docker images for your Selenium Grid hub and node(s)
Add Java to the hub to run the Selenium server jar
Add Java, plus Firefox and Xvfb to the node (Xvfb is an X server that can run on
machines with no display hardware and no physical input devices. It emulates a dumb
framebuffer using virtual memory.)
Create a docker-compose.yml file to define how the images will interact with each other
Start docker-compose and scale out to as many nodes as you need – or that your
machine can handle
http://www.conductor.com/nightlight/running-selenium-grid-using-docker-compose/
Steps for setup
Responsive Web design Testing
About Galen
Layout testing with GALEN
Responsive web design Testing
http://www.hangar17.in/en/responsive-webdesign
Pages should be readable on all resolutions
Text, Image alignment, controls
Color, shading, gradient consistency
What to Test
Selecting different set of devices for test
Frequent changes in requirements
Do emulators / simulators all the devices in the market
Tools
Applitools
Viewport Resize for Chrome
Galen
Challenges
Its open source
Build with Responsive Web design in Mind
Uses Selenium for web page interactions
Developed by : Ivan Subin
Galen Framework
How Galen Works
Sample Spec File
Test Report
Detailed Report
Maven – build automation tool
Maven – a build automation tool which is distributed under Apache Software
Foundation. It is mainly used for java projects. It makes build consistent with other
project.
Maven is used to manage the dependencies.
Maven provides pom.xml which is the core to any project.
Maven stores all project jars. Library jar are in place called repository which could
be central, local or remote repository.
<repositories>
<repository>
<id>libraryId</id>
<url>http://comanyrepositryId</url>
</repository>
</repositories>
Project example
Command to run → mvn clean test
Git – Code Repository
Git Hub is a Collaboration platform. It is built on top of git. It allows you to keep
both local and remote copies of your project. A project which you can publish it
among your team members as they can use it and update it from there itself.
Advantages :
Multiple people when they work on the same project they can update project
details and inform other team members simultaneously.
Jenkins can help us to regularly build the project from the remote repository
this helps us to keep track of failed builds.
Setup
Jenkins is the leading open-source continuous integration tool
developed by Hudson lab. It is cross-platform and can be used on
Windows, Linux, Mac OS and Solaris environments. It fires pre-
configured actions when a particular step occurs in jobs.
Jenkins
 Running Selenium tests in Jenkins allows you to run your tests every time
your software changes and deploy the software to a new environment
 Jenkins can schedule your tests to run at specific time.
 You can save the execution history and Test Reports.
 Jenkins supports Maven for building and testing a project in continuous
integration.
 Jenkins supports Docker plugin
Why – Jenkins and Selenium
Docker - > http://blog.unicsolution.com/2015/07/scale-selenium-grid-in-5-seconds-with.html
Docker Conference : https://confengine.com/selenium-conf-2015/proposal/1365/docker-
selenium-getting-started
Galen : http://galenframework.com/
Extent Reporting : http://extentreports.relevantcodes.com
My Blog : http://gururajhm.blogspot.in/p/welcome.html
Selenium Git Hub : https://github.com/SeleniumHQ/selenium
Page object Model : http://martinfowler.com/bliki/PageObject.html
https://code.google.com/p/selenium/wiki/PageFactory
http://seleniumhq.github.io/selenium/docs/api/java/index.html
References
Mastering Test Automation: How To Use Selenium Successfully

Weitere ähnliche Inhalte

Was ist angesagt?

Improve Development Process with Open Source Software
Improve Development Process with Open Source SoftwareImprove Development Process with Open Source Software
Improve Development Process with Open Source Software
elliando dias
 
Continuous integration / deployment with Jenkins
Continuous integration / deployment with JenkinsContinuous integration / deployment with Jenkins
Continuous integration / deployment with Jenkins
cherryhillco
 
2013 10-28 php ug presentation - ci using phing and hudson
2013 10-28 php ug presentation - ci using phing and hudson2013 10-28 php ug presentation - ci using phing and hudson
2013 10-28 php ug presentation - ci using phing and hudson
Shreeniwas Iyer
 
Continuous Integration (Jenkins/Hudson)
Continuous Integration (Jenkins/Hudson)Continuous Integration (Jenkins/Hudson)
Continuous Integration (Jenkins/Hudson)
Dennys Hsieh
 

Was ist angesagt? (20)

Improve Development Process with Open Source Software
Improve Development Process with Open Source SoftwareImprove Development Process with Open Source Software
Improve Development Process with Open Source Software
 
What is Jenkins | Jenkins Tutorial for Beginners | Edureka
What is Jenkins | Jenkins Tutorial for Beginners | EdurekaWhat is Jenkins | Jenkins Tutorial for Beginners | Edureka
What is Jenkins | Jenkins Tutorial for Beginners | Edureka
 
Automate your build on Android with Jenkins
Automate your build on Android with JenkinsAutomate your build on Android with Jenkins
Automate your build on Android with Jenkins
 
Test driven development_continuous_integration
Test driven development_continuous_integrationTest driven development_continuous_integration
Test driven development_continuous_integration
 
Jenkins CI
Jenkins CIJenkins CI
Jenkins CI
 
Continuous Integration at T3CON08
Continuous Integration at T3CON08Continuous Integration at T3CON08
Continuous Integration at T3CON08
 
Continuous integration / deployment with Jenkins
Continuous integration / deployment with JenkinsContinuous integration / deployment with Jenkins
Continuous integration / deployment with Jenkins
 
2013 10-28 php ug presentation - ci using phing and hudson
2013 10-28 php ug presentation - ci using phing and hudson2013 10-28 php ug presentation - ci using phing and hudson
2013 10-28 php ug presentation - ci using phing and hudson
 
Continuous Testing using Shippable and Docker
Continuous Testing using Shippable and DockerContinuous Testing using Shippable and Docker
Continuous Testing using Shippable and Docker
 
Testing desktop apps with selenium
Testing desktop apps with seleniumTesting desktop apps with selenium
Testing desktop apps with selenium
 
Story Testing Approach for Enterprise Applications using Selenium Framework
Story Testing Approach for Enterprise Applications using Selenium FrameworkStory Testing Approach for Enterprise Applications using Selenium Framework
Story Testing Approach for Enterprise Applications using Selenium Framework
 
Continuous Integration, Build Pipelines and Continuous Deployment
Continuous Integration, Build Pipelines and Continuous DeploymentContinuous Integration, Build Pipelines and Continuous Deployment
Continuous Integration, Build Pipelines and Continuous Deployment
 
Jenkins as the Test Reporting Framework
Jenkins as the Test Reporting FrameworkJenkins as the Test Reporting Framework
Jenkins as the Test Reporting Framework
 
Docker в автоматизации тестирования
Docker в автоматизации тестированияDocker в автоматизации тестирования
Docker в автоматизации тестирования
 
Continuous Integration (Jenkins/Hudson)
Continuous Integration (Jenkins/Hudson)Continuous Integration (Jenkins/Hudson)
Continuous Integration (Jenkins/Hudson)
 
Building a CICD pipeline for deploying to containers
Building a CICD pipeline for deploying to containersBuilding a CICD pipeline for deploying to containers
Building a CICD pipeline for deploying to containers
 
CI/CD with Jenkins and Docker - DevOps Meetup Day Thailand
CI/CD with Jenkins and Docker - DevOps Meetup Day ThailandCI/CD with Jenkins and Docker - DevOps Meetup Day Thailand
CI/CD with Jenkins and Docker - DevOps Meetup Day Thailand
 
Jenkins - From Continuous Integration to Continuous Delivery
Jenkins - From Continuous Integration to Continuous DeliveryJenkins - From Continuous Integration to Continuous Delivery
Jenkins - From Continuous Integration to Continuous Delivery
 
Testing in DevOps world
Testing in DevOps worldTesting in DevOps world
Testing in DevOps world
 
Testing with Jenkins, Selenium and Continuous Deployment
Testing with Jenkins, Selenium and Continuous DeploymentTesting with Jenkins, Selenium and Continuous Deployment
Testing with Jenkins, Selenium and Continuous Deployment
 

Ähnlich wie Mastering Test Automation: How To Use Selenium Successfully

Stepin evening presented
Stepin evening presentedStepin evening presented
Stepin evening presented
Vijayan Reddy
 
Automation with Selenium Presented by Quontra Solutions
Automation with Selenium Presented by Quontra SolutionsAutomation with Selenium Presented by Quontra Solutions
Automation with Selenium Presented by Quontra Solutions
Quontra Solutions
 
Sakai10 Selenium Workshop
Sakai10 Selenium WorkshopSakai10 Selenium Workshop
Sakai10 Selenium Workshop
coreyjack
 

Ähnlich wie Mastering Test Automation: How To Use Selenium Successfully (20)

Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!
Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!
Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!
 
Stepin evening presented
Stepin evening presentedStepin evening presented
Stepin evening presented
 
Automation - web testing with selenium
Automation - web testing with seleniumAutomation - web testing with selenium
Automation - web testing with selenium
 
Selenium Automation Testing Interview Questions And Answers
Selenium Automation Testing Interview Questions And AnswersSelenium Automation Testing Interview Questions And Answers
Selenium Automation Testing Interview Questions And Answers
 
Good practices for debugging Selenium and Appium tests
Good practices for debugging Selenium and Appium testsGood practices for debugging Selenium and Appium tests
Good practices for debugging Selenium and Appium tests
 
Selenium
SeleniumSelenium
Selenium
 
Test Automation Framework Development Introduction
Test Automation Framework Development IntroductionTest Automation Framework Development Introduction
Test Automation Framework Development Introduction
 
Manageable Robust Automated Ui Test
Manageable Robust Automated Ui TestManageable Robust Automated Ui Test
Manageable Robust Automated Ui Test
 
Automation with Selenium Presented by Quontra Solutions
Automation with Selenium Presented by Quontra SolutionsAutomation with Selenium Presented by Quontra Solutions
Automation with Selenium Presented by Quontra Solutions
 
Sakai10 Selenium Workshop
Sakai10 Selenium WorkshopSakai10 Selenium Workshop
Sakai10 Selenium Workshop
 
Codeception
CodeceptionCodeception
Codeception
 
Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013
Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013
Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013
 
The Web on OSGi: Here's How
The Web on OSGi: Here's HowThe Web on OSGi: Here's How
The Web on OSGi: Here's How
 
Selenium.pptx
Selenium.pptxSelenium.pptx
Selenium.pptx
 
Session on Selenium Powertools by Unmesh Gundecha
Session on Selenium Powertools by Unmesh GundechaSession on Selenium Powertools by Unmesh Gundecha
Session on Selenium Powertools by Unmesh Gundecha
 
Pragmatic Parallels: Java and JavaScript
Pragmatic Parallels: Java and JavaScriptPragmatic Parallels: Java and JavaScript
Pragmatic Parallels: Java and JavaScript
 
Selenium interview-questions-freshers
Selenium interview-questions-freshersSelenium interview-questions-freshers
Selenium interview-questions-freshers
 
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)Selenium & PHPUnit made easy with Steward (Berlin, April 2017)
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)
 
Selenium - Introduction
Selenium - IntroductionSelenium - Introduction
Selenium - Introduction
 
Spring boot
Spring bootSpring boot
Spring boot
 

Mehr von SpringPeople

Mehr von SpringPeople (20)

Growth hacking tips and tricks that you can try
Growth hacking tips and tricks that you can tryGrowth hacking tips and tricks that you can try
Growth hacking tips and tricks that you can try
 
Top Big data Analytics tools: Emerging trends and Best practices
Top Big data Analytics tools: Emerging trends and Best practicesTop Big data Analytics tools: Emerging trends and Best practices
Top Big data Analytics tools: Emerging trends and Best practices
 
Introduction to Big Data
Introduction to Big DataIntroduction to Big Data
Introduction to Big Data
 
Introduction to Microsoft Azure IaaS
Introduction to Microsoft Azure IaaSIntroduction to Microsoft Azure IaaS
Introduction to Microsoft Azure IaaS
 
Introduction to Selenium WebDriver
Introduction to Selenium WebDriverIntroduction to Selenium WebDriver
Introduction to Selenium WebDriver
 
Introduction to Open stack - An Overview
Introduction to Open stack - An Overview Introduction to Open stack - An Overview
Introduction to Open stack - An Overview
 
Best Practices for Administering Hadoop with Hortonworks Data Platform (HDP) ...
Best Practices for Administering Hadoop with Hortonworks Data Platform (HDP) ...Best Practices for Administering Hadoop with Hortonworks Data Platform (HDP) ...
Best Practices for Administering Hadoop with Hortonworks Data Platform (HDP) ...
 
Why 2 million Developers depend on MuleSoft
Why 2 million Developers depend on MuleSoftWhy 2 million Developers depend on MuleSoft
Why 2 million Developers depend on MuleSoft
 
Mongo DB: Fundamentals & Basics/ An Overview of MongoDB/ Mongo DB tutorials
Mongo DB: Fundamentals & Basics/ An Overview of MongoDB/ Mongo DB tutorialsMongo DB: Fundamentals & Basics/ An Overview of MongoDB/ Mongo DB tutorials
Mongo DB: Fundamentals & Basics/ An Overview of MongoDB/ Mongo DB tutorials
 
An Introduction of Big data; Big data for beginners; Overview of Big Data; Bi...
An Introduction of Big data; Big data for beginners; Overview of Big Data; Bi...An Introduction of Big data; Big data for beginners; Overview of Big Data; Bi...
An Introduction of Big data; Big data for beginners; Overview of Big Data; Bi...
 
SpringPeople - Introduction to Cloud Computing
SpringPeople - Introduction to Cloud ComputingSpringPeople - Introduction to Cloud Computing
SpringPeople - Introduction to Cloud Computing
 
SpringPeople - Devops skills - Do you have what it takes?
SpringPeople - Devops skills - Do you have what it takes?SpringPeople - Devops skills - Do you have what it takes?
SpringPeople - Devops skills - Do you have what it takes?
 
Elastic - ELK, Logstash & Kibana
Elastic - ELK, Logstash & KibanaElastic - ELK, Logstash & Kibana
Elastic - ELK, Logstash & Kibana
 
Hadoop data access layer v4.0
Hadoop data access layer v4.0Hadoop data access layer v4.0
Hadoop data access layer v4.0
 
Introduction To Core Java - SpringPeople
Introduction To Core Java - SpringPeopleIntroduction To Core Java - SpringPeople
Introduction To Core Java - SpringPeople
 
Introduction To Hadoop Administration - SpringPeople
Introduction To Hadoop Administration - SpringPeopleIntroduction To Hadoop Administration - SpringPeople
Introduction To Hadoop Administration - SpringPeople
 
Introduction To Cloud Foundry - SpringPeople
Introduction To Cloud Foundry - SpringPeopleIntroduction To Cloud Foundry - SpringPeople
Introduction To Cloud Foundry - SpringPeople
 
Introduction To Spring Enterprise Integration - SpringPeople
Introduction To Spring Enterprise Integration - SpringPeopleIntroduction To Spring Enterprise Integration - SpringPeople
Introduction To Spring Enterprise Integration - SpringPeople
 
Introduction To Groovy And Grails - SpringPeople
Introduction To Groovy And Grails - SpringPeopleIntroduction To Groovy And Grails - SpringPeople
Introduction To Groovy And Grails - SpringPeople
 
Introduction To Jenkins - SpringPeople
Introduction To Jenkins - SpringPeopleIntroduction To Jenkins - SpringPeople
Introduction To Jenkins - SpringPeople
 

Kürzlich hochgeladen

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Kürzlich hochgeladen (20)

Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 

Mastering Test Automation: How To Use Selenium Successfully

  • 1. by Gururaj Learn How To Use Selenium Successfully In Conjunction With Other Tools
  • 2. • We have INSTRUCTOR -LED - both Online LIVE & Classroom Session  Present for classroom sessions in Bangalore & Delhi (NCR)  We are the ONLY Education delivery partners for Mulesoft, Elastic, Pivotal & Lightbend in India  We have delivered more than 5000 trainings and have over 400 courses and a vast pool of over 200 experts to make YOU the EXPERT!  FOLLOW US ON SOCIAL MEDIA TO STAY UPDATED ON THE UPCOMING WEBINARS
  • 3. Non-Certified Courses …and many more Certified Partners
  • 4. • Selenium tool • Write maintainable and reusable Selenium scripts • Reporting Structure by using external plugin's • Cross browser testing (Running selenium grid with Docker) • UI layout test using Galen framework • Maven– automation build tool • Code repository (Git) • Jenkins CI tool Agenda
  • 5.
  • 6. Selenium Selenium is the best open source tool for doing automation for web based application and it does not have any cost attached to it. The only cost is the effort which will go for designing and developing the script for the application. Selenium scripting can be done in a number of programming languages like C#, Perl, PHP, Ruby, Java etc, unlike other commercial tools which support single scripting language. Since Selenium scripting can be done in any language of choice, one can easily find right resources for the programming language chosen for Selenium Automation. Last but not the least, since this tool comes at ZERO PRICE, an organization’s management will find that the only investment they have made is on the infrastructure and human effort and not on the heavy licensing cost. IDE WebDriver Grid
  • 7.  Selenium uses what is called locators to find and match the elements of your page that it needs to interact with:  Link  XPath  ID  Name  CSS Locators
  • 11. Page object generator - Plugin Selenium Page Object Generator is an essential tool to improve your workflow. It will generate Page Object Model on active Chrome tab with a single click, provided that all the options and template are configured. The generated Page Object Model will be saved to pre-configured Chrome download folder. It strives to reduce manual involvement, but manual tweak still recommended
  • 13. Preferred selector order to locators ; Preferred Order ID Locator NAME Locator CSS Locator XPATH Locator
  • 14.  Thread.sleep  Implicit Waits  Explicit Waits  FluentWait Implicit waits :Once set, the implicit wait is set for the life of the WebDriver object instance. Explicit waits: An explicit waits is code you define to wait for a certain condition to occur before proceeding further in the code Exception Handling
  • 15. Expected Conditions Because it's quite a common occurrence to have to synchronize the DOM and your instructions, most clients also come with a set of predefined expected conditions. As might be obvious by the name, they are conditions that are predefined for frequent wait operations. The conditions available in the different language bindings vary, but this is a non- exhaustive list of a few: alert is present element exists element is visible title contains title is visible text Expected Conditions
  • 16. Expected Conditions Because it's quite a common occurrence to have to synchronize the DOM and your instructions, most clients also come with a set of predefined expected conditions. As might be obvious by the name, they are conditions that are predefined for frequent wait operations. The conditions available in the different language bindings vary, but this is a non- exhaustive list of a few: alert is present element exists element is visible title contains title is visible text Expected Conditions
  • 17. Sample code... Problem : open Jquery component and try to get tooltip for the textbox
  • 19. FluentWait instance defines the maximum amount of time to wait for a condition, as well as the frequency with which to check the condition. User may configure the wait to ignore specific types of exceptions whilst waiting, such as NoSuchElementExceptions when searching for an element on the page. // Waiting 30 seconds for an element to be present on the page, checking // for its presence once every 5 seconds. Wait<WebDriver> wait = new FluentWait<WebDriver>(driver) .withTimeout(30, SECONDS) .pollingEvery(5, SECONDS) .ignoring(NoSuchElementException.class); WebElement foo = wait.until(new Function<WebDriver, WebElement>() { public WebElement apply(WebDriver driver) { return driver.findElement(By.id("foo")); } }); Fluent Waits
  • 20.  Common functions or Keywords  Click, Verify, Wait for Element, EnterText, SelectBox etc..  Page Object Model / Factory Reusability
  • 22.  Page Object Model is a design pattern to create Object Repository for web  UI elements.  Under this model, for each web page in the application there should be corresponding page class.  This Page class will find the WebElements of that web page and also contain page methods which perform operations on those WebElements.  Name of these methods should be given as per the task they are performing Page Object Model
  • 24. Page Factory Page Factory is an inbuilt page object model concept for Selenium WebDriver @FindBy elements - use of @FindBy annotations. With this annotation, we can define a strategy for looking up the element, along with the necessary information for identifying it: @FindBy can accept tagName, partialLinkText, name, linkText, id, css, className, xpath as attributes.
  • 26. LoginPage = PageFactory.initElements(driver, LoginPagePOF.class); } @Test public void test() { LoginPage.LogIn_Action("guest", "guest"); System.out.println(" Login Successfully, now it is the time to Log Off buddy."); } Page Factory Page Factory Class To initialize WebElements
  • 27. Page Factory - Project Page Factory TestNG classes Test Data Config Utility Factory Reports Screen Shots Logs ` ` ` `
  • 28. Generating reports is always challenge with Selenium, since it doesn't comes with any reporting features. There are lot of plugin's available will see in action; REPORTING XSLT Report NG ATU Reports Extent
  • 29. <target name="xsltreports"> <mkdir dir="${basedir}/XSLT_Reports/output"/> <xslt in="${ng.result}/testng-results.xml" style="src/com/xslt/testng-results.xsl" out="${basedir}/XSLT_Reports/output/index.html" classpathref="classpath_jars" processor="SaxonLiaison"> <param name="testNgXslt.outputDir" expression="${basedir}/XSLT_Reports/output/"/> <param name="testNgXslt.showRuntimeTotals" expression="true"/> </xslt> </target> XSLT - Reporting Create ANT task in build.xml file with target
  • 31. ReportNG is a simple HTML reporting plug-in for the TestNGunit-testing framework. It is intended as a replacement for the default TestNG HTML report. The default report is comprehensive but is not so easy to understand at-a-glance. ReportNG provides a simple, colour-coded view of the test results. ReportNG generates 100% valid XHTML 1.0 files. The output can be customised by over-riding the default stylesheet with your own CSS file. ReportNG - Plugin
  • 33. Very simple to use API Beautiful and responsive UI Provides dashboard for the entire run Parallel execution of classes and methods supported Creates a single report file, so less management of artifacts required (Online only*, Offline report stores all artifacts locally) Separate section for categories, provides analysis of tests by category Easily integrate test-runner logs Can be customized heavily using an external config file and this is developed by http://extentreports.relevantcodes.com Extent Reports - Plugin
  • 34. Very simple to use API Beautiful and responsive UI Provides dashboard for the entire run Parallel execution of classes and methods supported Creates a single report file, so less management of artifacts required (Online only*, Offline report stores all artifacts locally) Separate section for categories, provides analysis of tests by category Easily integrate test-runner logs Can be customized heavily using an external config file and this is developed by http://extentreports.relevantcodes.com Extent Reports - Plugin
  • 36. ATU Reporter is free open source plugin/utility for Selenium. This will be a TestNG listener for generating customized graphical reports. Following reports can be generated by this listener. Line Charts Bar Charts Pie Charts <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd"> <suite name="Suite" parallel="false"> <test name="Test"> <classes> <class name="com.test.AUTReporting.ReporterGoogleTest"/> </classes> </test> <listeners> <listener class-name="atu.testng.reports.listeners.ATUReportsListener"></listener> <listener class-name="atu.testng.reports.listeners.ConfigurationListener"></listener> <listener class-name="atu.testng.reports.listeners.MethodListener"></listener> </listeners> </suite> ATU Reports - Plugin
  • 38. Cross Browser Testing is a type of functional test to check that your web application works as expected in different browsers. Cross Browser Testing
  • 39. CBT – With cloud services Running test on local machine with different OS with different combination of browsers its always a challenge, either we need to get more machine and really on selenium grid to solve the problem. Now without installing any OS or browser can we run the selenium scripts on cloud, yes its possible with some of the cloud services like Testing bot Sauce lab BrowserSTack. public static final String KEY = "your key paste here"; public static final String SECRET = "your secret paste here"; public static final String URL = "http://" + KEY + ":" + SECRET + "@hub.testingbot.com/wd/hub"; public static void main(String[] args) throws IOException, InterruptedException { // TODO Auto-generated method stub DesiredCapabilities caps = new DesiredCapabilities(); caps.setCapability("platform", "WIN8"); caps.setCapability("version", "35"); caps.setCapability("browserName", "chrome"); // Remote web driver to register with testing bot key and secret, so that it will launch browser on these machines driver = new RemoteWebDriver(new URL(URL), caps); driver.get("https://timetracker.anuko.com/login.php"); Grid with Cloud Services
  • 40.  In simple words, Docker – with use of linux-containers – allows you to pack all your application dependencies, like database, system libraries and so on, into standardized and portable units, called containers.  You don’t need to ship entire OS to your CI or production server.  We can manage this with containers with independent units. Selenium Grid with Docker
  • 41. Docker is a lightweight container (read: a scaled-down VM) that provides a fast and programmatic way to run distributed applications. Selenium Grid is distributed system of nodes for running tests. Instead of running your grid across multiple machines or VMs, you can run them all on a single large machine using Docker. `docker-selenium` project is about packaging selenium grid as docker containers (https://github.com/seleniumhq/docker-selenium) We don't have to build any selenium infrastructure machines. I just run the provided images by docker-selenium project (https://hub.docker.com/r/selenium/). We don't have to install selenium jar, java, browsers and other runtime dependencies. They are already built in a docker image and I can just run them as either selenium grid with hub and nodes or as standalone selenium on any docker engine enabled vm. Docker
  • 42. Setup
  • 43. Create Docker images for your Selenium Grid hub and node(s) Add Java to the hub to run the Selenium server jar Add Java, plus Firefox and Xvfb to the node (Xvfb is an X server that can run on machines with no display hardware and no physical input devices. It emulates a dumb framebuffer using virtual memory.) Create a docker-compose.yml file to define how the images will interact with each other Start docker-compose and scale out to as many nodes as you need – or that your machine can handle http://www.conductor.com/nightlight/running-selenium-grid-using-docker-compose/ Steps for setup
  • 44. Responsive Web design Testing About Galen Layout testing with GALEN
  • 45. Responsive web design Testing http://www.hangar17.in/en/responsive-webdesign
  • 46. Pages should be readable on all resolutions Text, Image alignment, controls Color, shading, gradient consistency What to Test
  • 47. Selecting different set of devices for test Frequent changes in requirements Do emulators / simulators all the devices in the market Tools Applitools Viewport Resize for Chrome Galen Challenges
  • 48. Its open source Build with Responsive Web design in Mind Uses Selenium for web page interactions Developed by : Ivan Subin Galen Framework
  • 53. Maven – build automation tool Maven – a build automation tool which is distributed under Apache Software Foundation. It is mainly used for java projects. It makes build consistent with other project. Maven is used to manage the dependencies. Maven provides pom.xml which is the core to any project. Maven stores all project jars. Library jar are in place called repository which could be central, local or remote repository. <repositories> <repository> <id>libraryId</id> <url>http://comanyrepositryId</url> </repository> </repositories>
  • 54. Project example Command to run → mvn clean test
  • 55. Git – Code Repository Git Hub is a Collaboration platform. It is built on top of git. It allows you to keep both local and remote copies of your project. A project which you can publish it among your team members as they can use it and update it from there itself. Advantages : Multiple people when they work on the same project they can update project details and inform other team members simultaneously. Jenkins can help us to regularly build the project from the remote repository this helps us to keep track of failed builds.
  • 56. Setup
  • 57. Jenkins is the leading open-source continuous integration tool developed by Hudson lab. It is cross-platform and can be used on Windows, Linux, Mac OS and Solaris environments. It fires pre- configured actions when a particular step occurs in jobs. Jenkins
  • 58.  Running Selenium tests in Jenkins allows you to run your tests every time your software changes and deploy the software to a new environment  Jenkins can schedule your tests to run at specific time.  You can save the execution history and Test Reports.  Jenkins supports Maven for building and testing a project in continuous integration.  Jenkins supports Docker plugin Why – Jenkins and Selenium
  • 59.
  • 60. Docker - > http://blog.unicsolution.com/2015/07/scale-selenium-grid-in-5-seconds-with.html Docker Conference : https://confengine.com/selenium-conf-2015/proposal/1365/docker- selenium-getting-started Galen : http://galenframework.com/ Extent Reporting : http://extentreports.relevantcodes.com My Blog : http://gururajhm.blogspot.in/p/welcome.html Selenium Git Hub : https://github.com/SeleniumHQ/selenium Page object Model : http://martinfowler.com/bliki/PageObject.html https://code.google.com/p/selenium/wiki/PageFactory http://seleniumhq.github.io/selenium/docs/api/java/index.html References