SlideShare a Scribd company logo
Automation Testing by
Selenium Web Driver
As efficient as your
in-house team
We provide the people, the ability
and the tools so you can be best at
what you do.
Automation Testing by Selenium Web Driver
Why automate testing?
Test automation has specific advantages for improving the
long-term efficiency of a software team’s testing processes.
Test automation supports:
0 Frequent regression testing
0 Rapid feedback to developers
0 Virtually unlimited iterations of test case execution
0 Support for Agile and extreme development methodologies
0 Disciplined documentation of test cases
0 Customized defect reporting
0 Finding defects missed by manual testing
Automation Test Life Cycle
Selenium History
0 2004 - at ThoughtWorks in Chicago, Jason Huggins built the Core mode as
"JavaScriptTestRunner" for the testing of an internal Time and Expenses
application (Python, Plone).
0 2006 - at Google, Simon Stewart started work on a project he called WebDriver.
Google had long been a heavy user of Selenium, but testers had to work around
the limitations of the product. The WebDriver project began with the aim to
solve the Selenium’ pain-points.
0 2008 - merging of Selenium and WebDriver. Selenium had massive community
and commercial support, but WebDriver was clearly the tool of the future. The
joining of the two tools provided a common set of features for all users and
brought some of the brightest minds in test automation under one roof.
0 Shinya Kasatani in Japan became interested in Selenium, he
0 Wrapped the core code into an IDE module into the Firefox browser
0 Added the ability to record tests as well as play them back in the same plugin.
0 This tool, turned out an eye opener in more ways that was originally thought as it is
not bound to the same origin policy.
0 See http://docs.seleniumhq.org/about/history.jsp for more interesting details
0 http://docs.seleniumhq.org/about/contributors.jsp
Selenium World
Which tool to use?
Selenium IDE
Script Syntax
0 Selenium scripts that will be run from Selenium-IDE
are stored in an HTML text file format.
0 HTML table with three columns.
0 The first column identifies the Selenium command
0 the second is a target, and
0 the final column contains a value.
0 The second and third columns may not require values
depending on the chosen Selenium command, but they
should be present.
0 Each table row represents a new Selenium command.
Commonly Used Selenium
Commands
 Open - opens a page using a URL.
 click/clickAndWait - performs a click operation, and optionally waits for a new
page to load.
 verifyTitle/assertTitle - verifies an expected page title.
 verifyTextPresent - verifies expected text is somewhere on the page.
 verifyElementPresent - verifies an expected UI element, as defined by its HTML
tag, is present on the page.
 verifyText - verifies expected text and its corresponding HTML tag are present on
the page.
 verifyTable - verifies a table’s expected contents.
 waitForPageToLoad - pauses execution until an expected new page loads.
Called automatically when clickAndWait is used.
 waitForElementPresent - pauses execution until an expected UI element, as
defined by its HTML tag, is present on the page.
Locating Elements
0 For many Selenium commands, a target is required. This
target identifies an element in the content of the web
application, and consists of the location strategy followed
by the location in the format locatorType=location
0 Locating by Identifier : the most common method of
locating elements and is the catch-all default when no
recognized locator type is used
0 the first element with the id attribute value matching the
location will be used. If no element has a matching id
attribute, then the first element with a name attribute
matching the location will be used
Locating Elements
0 Locating by Id: more limited than the identifier locator
type, but also more explicit.
0 Use this when you know an element’s id attribute.
0 Locating by Name: will locate the first element with a
matching name attribute. If multiple elements have the
same value for a name attribute, then you can use filters
to further refine your location strategy.
0 The default filter type is value (matching the value
attribute).
Locating Elements
0 Locating by Xpath : XPath extends beyond (as well as
supporting) the simple methods of locating by id or name
attributes, and opens up all sorts of new possibilities such as
locating the third checkbox on the page.
0 Since only xpath locators start with “//”, it is not necessary to
include the xpath= label when specifying an XPath locator.
0 Absolute XPaths contain the location of all elements from the root
(html) and as a result are likely to fail with only the slightest
adjustment to the application. By finding a nearby element with
an id or name attribute (ideally a parent element) you can locate
your target element based on the relationship. This is much less
likely to change and can make your tests more robust.
Locating Elements
0 Locating Hyperlinks by Link Text: simple method of
locating a hyperlink in your web page by using the text of
the link. If two links with the same text are present, then
the first match will be used.
0 Locating by CSS: CSS uses Selectors for binding style
properties to elements in the document. These Selectors
can be used by Selenium as another locating strategy.
0 Most experienced Selenium users recommend CSS as their
locating strategy of choice as it’s considerably faster than
XPath and can find the most complicated objects in an
intrinsic HTML document.
Matching Text Patterns
0 Like locators, patterns are a type of parameter frequently
required by Selenese commands.
0 Examples of commands which require patterns are
0 verifyTextPresent,
0 verifyTitle,
0 verifyAlert,
0 assertConfirmation,
0 verifyText, and
0 verifyPrompt.
0 link locators can utilize a pattern.
0 Patterns allow you to describe, via the use of special characters,
what text is expected rather than having to specify that text
exactly.
Landing Page
Recording User Actions
Save Test Case Script as HTML
Inspecting Element in mozilla
Extracting Element by css
Executing Script by CSS.
Extracting xpath
Xpath by Xpath Checker
Xpath is a very Helpful to validate Xpath on pages. In order to write xpath
expressions we should look at the tree structure of html source code and based
On the path for require element we should drive the xpath expression.
/html/body/a - It will Identify all the elements are using a tag.
/html/body/input - It will Identify all the elements are using input tag.
/html/body/input[1] – It will Identify the first input tag under body.
/html/body/a/img – xpath for a image present on a link.
/html/body/table/tbody/tr[2]/td[1] – It will Identify the element which
is present in 2nd tr contain 1st td inside tbody.
/html/body/div//a – It will identify all “a” tag present in the all div present
on html body.
Generally we use xpath by position along with xpath by attribute.
Ex-
/html/body/input[@id=‘UN’]
//input[@value=‘login’]
//a[@href=‘http://www.cuelogic.com/’]
//a[text()=‘Cuelogic’] – This xpath will identify the element by text “Cuelogic”
//a[contains[text(), ‘Cuelogic’]] – This xpath will also identify the element by text
“Cuelogic” but if their any spaces at beginning or at end
it will consider it.
//td[a] - “[ ]” denotes select all while “/” denote as parent to element path ignore all
other elements in tree same Structure.
Htmltag[@PN=‘PV’]
Identify the Dependent and Independent Elements-
Derived xpath expression for the dependent element from the common parent
//tr[td[a[text()=‘Cuelogic’]]]/td[3]/input
Write a xpath for independent element –
//a[text()=‘Cuelogic’]
Executing script by xpath
Edit Script and find element
by xpath
Creating Suite
Saving Suite
A few tips
0 Saving a test suite does not save the test case.
0 Make sure that you save the test case every time you
make a change and not just the test suite.
0 echo - The Selenese Print Command
0 Use Find button to see which UI element on the
currently displayed webpage (in the browser) is used
in the currently selected Selenium command. This is
useful when building a locator for a command’s first
parameter
Selenium IDE –
Limitations/Drawbacks
0 Firefox only
0 Can not Specify any condition Statement.
0 Can not Specify any Looping Statement.
0 Can not take external text data from External
Resources such as XLS,XML or Database.
0 Handing Exceptions is not in scope.
0 Note:- To overcome the limitation of Selenium IDE we
go for Selenium WebDriver.
Selenium Web Driver
0 WebDriver is a tool for automating web application
testing, and in particular to verify that they work as
expected.
0 It aims to provide a friendly API that’s easy to explore
and understand, easier to use than the Selenium-RC
(1.0) API, which will help to make your tests easier to
read and maintain.
0 It’s not tied to any particular test framework, so it can
be used equally well in a unit testing or from a plain
old “main” method.
Selenium Web Driver –
Browser Support
Selenium-WebDriver supports the following browsers along
with the operating systems these browsers are compatible
with.
0 Google Chrome
0 Internet Explorer
0 Firefox
0 Opera 11.5+
0 HtmlUnit
0 Android – 2.3+ for phones and tablets (devices & emulators)
0 iOS 3+ for phones (devices & emulators) and 3.2+ for tablets
(devices & emulators)
WebDriver &
Selenium-Server
Some reasons to use the Selenium-Server with
Selenium-WebDriver.
0 You are using Selenium-Grid to distribute your tests
over multiple machines or virtual machines (VMs).
0 You want to connect to a remote machine that has a
particular browser version that is not on your current
machine.
0 You are not using the Java bindings (i.e. Python, C#, or
Ruby) and would like to use HtmlUnit Driver
Install/Configure Webdriver
with Eclipse.
Creating Project
Automation Testing by Selenium Web Driver
Automation Testing by Selenium Web Driver
Simple Architecture of
WebDriver
WEBDRIVER(i)
Remote Webdriver
Firefox Driver Chrome Driver
Internet Explorer
Driver
Interface
Protected class
Selenium First Code
Browser open by Webdriver.
Methods:- “findElement” is a method of webdriver interface which is
Use to identify required element in the application. This method takes an
Object as an argument of type “By”.
Locators:- Webdriver supports 8 types of locators to identify the
Elements and all the locators will return the object of the type
Webelements.
Types of Locators:-
1. By.id(arg)
2. By.name(String)
3. By.xpath(String xpathExpression)
4. By.cssSelector(String Selector)
5. By.linkText(String linkText)
6. By.partialLinkText(String linkText)
7. By.className(String className)
8. By.tagName(String Name)
Locator Code:-
Locator Code impact.
Retrieving the value from
application
While doing validation we compare excepted result and actual
result then we will report the status. Actual result will be taken from
application during runtime. In order to do this we use following important
Method.
1. getTitle() :- This method help us to retrieve the title of the webpage.
2. GetcurrentUrl():- This method will retrieve the current url from the
address bar of the browser.
3. getAttribute(“value”) :- This is used to retrieve property value from the
element present in the application. It is basically used to retrieve text from
Textbox, password field, Address Field, Path of uploading file and button
name.
4. isEnable() :- This method is used to check whether the specify elements
enable or not. True indicates enable and false indicates disable.
5. isSelected() :- It is used to checked whether the specific checkbox or radio
button is selected or not.
6. getText():- It is used to retrieve the text of the following element.
Windows Handles
Browser Operations
1. Navigate back to Previous Page:-
driver.navigate().back();
2. Navigate to the next Page:-
driver.navigate().forward();
3. Refresh Mehods :-
driver.navigate().refresh();
Handling Frames
Q: How do I execute Javascript directly?
A: WebDriver driver; // Assigned elsewhere
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("return document.title");
Q: The InternetExplorerDriver does not work well on Vista.
How do I get it to work as expected?
A:DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer();
capabilities.setCapability(InternetExplorerDriver.
INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
WebDriver driver = new InternetExplorerDriver(capabilities);
Q: Does WebDriver support Javascript alerts and prompts?
A: // Get a handle to the open alert, prompt or confirmation
Alert alert = driver.switchTo().alert(); // Get the text of the alert or prompt
alert.getText();
// And acknowledge the alert (equivalent to clicking "OK")
alert.accept();
//And to decline alert
Alert.dismiss();
Q: I need to use a proxy. How do I configure that?
A: Proxy configuration is done via the org.openqa.selenium.Proxy class like so:
Proxy proxy = new Proxy();
proxy.setProxyAutoconfigUrl("http://youdomain/config");
// We use firefox as an example here.
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability(CapabilityType.PROXY, proxy);
// You could use any webdriver implementation here
WebDriver driver = new FirefoxDriver(capabilities);
Q: WebDriver fails to start Firefox on Linux due to java.net.SocketException
A: If, when running WebDriver on Linux, Firefox fails to start and the error looks like:
Caused by:
java.net.SocketException: Invalid argument
at java.net.PlainSocketImpl.socketBind(Native Method)
at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:365)
at java.net.Socket.bind(Socket.java:571)
at org.openqa.selenium.firefox.internal.SocketLock.isLockFree(SocketLock.java:99)
at org.openqa.selenium.firefox.internal.SocketLock.lock(SocketLock.java:63)
It may be caused due to IPv6 settings on the machine. Execute:
sudo sysctl net.ipv6.bindv6only=0
Framework Execution Flow
Keyword driver automation framework:-
Automation Testing by Selenium Web Driver
Selenium RC
Selenium RC comes in two
parts.
A server which automatically
launches and kills browsers,
and acts as a HTTP proxy for
web requests from them.
Client libraries for your
favorite computer language.
References
0 http://docs.seleniumhq.org/
0 Selenium and Section 508 by David Sills
0 http://java.dzone.com/articles/selenium-and-section-508
0 Selenium Tutorial for Beginner/Tips for Experts
0 http://www.jroller.com/selenium/
0 Get Test-Infected With Selenium
0 http://net.tutsplus.com/tutorials/tools-and-tips/get-test-
infected-with-selenium-2/
0 https://code.google.com/p/selenium/
Books
Thanks
&
enjoy the rest of the code
camp 

More Related Content

What's hot

Selenium
SeleniumSelenium
Selenium
Kalyan ch
 
An overview of selenium webdriver
An overview of selenium webdriverAn overview of selenium webdriver
An overview of selenium webdriver
Anuraj S.L
 
Selenium Presentation at Engineering Colleges
Selenium Presentation at Engineering CollegesSelenium Presentation at Engineering Colleges
Selenium Presentation at Engineering Colleges
Vijay Rangaiah
 
Introduction to Selenium Web Driver
Introduction to Selenium Web DriverIntroduction to Selenium Web Driver
Introduction to Selenium Web Driver
Return on Intelligence
 
Automation Testing using Selenium Webdriver
Automation Testing using Selenium WebdriverAutomation Testing using Selenium Webdriver
Automation Testing using Selenium Webdriver
Pankaj Biswas
 
Selenium WebDriver Tutorial | Selenium WebDriver Tutorial For Beginner | Sele...
Selenium WebDriver Tutorial | Selenium WebDriver Tutorial For Beginner | Sele...Selenium WebDriver Tutorial | Selenium WebDriver Tutorial For Beginner | Sele...
Selenium WebDriver Tutorial | Selenium WebDriver Tutorial For Beginner | Sele...
Simplilearn
 
Selenium WebDriver
Selenium WebDriverSelenium WebDriver
Selenium WebDriver
Yuriy Bezgachnyuk
 
Selenium ppt
Selenium pptSelenium ppt
Selenium ppt
Anirudh Raja
 
Selenium- A Software Testing Tool
Selenium- A Software Testing ToolSelenium- A Software Testing Tool
Selenium- A Software Testing Tool
Zeba Tahseen
 
QSpiders - Automation using Selenium
QSpiders - Automation using SeleniumQSpiders - Automation using Selenium
QSpiders - Automation using Selenium
Qspiders - Software Testing Training Institute
 
Automation Testing using Selenium
Automation Testing using SeleniumAutomation Testing using Selenium
Automation Testing using Selenium
Naresh Chintalcheru
 
Selenium Tutorial For Beginners | Selenium Automation Testing Tutorial | Sele...
Selenium Tutorial For Beginners | Selenium Automation Testing Tutorial | Sele...Selenium Tutorial For Beginners | Selenium Automation Testing Tutorial | Sele...
Selenium Tutorial For Beginners | Selenium Automation Testing Tutorial | Sele...
Simplilearn
 
Automated Web Testing Using Selenium
Automated Web Testing Using SeleniumAutomated Web Testing Using Selenium
Automated Web Testing Using Selenium
Weifeng Zhang
 
Selenium IDE Tutorial For Beginners | Selenium IDE Tutorial | What Is Seleniu...
Selenium IDE Tutorial For Beginners | Selenium IDE Tutorial | What Is Seleniu...Selenium IDE Tutorial For Beginners | Selenium IDE Tutorial | What Is Seleniu...
Selenium IDE Tutorial For Beginners | Selenium IDE Tutorial | What Is Seleniu...
Simplilearn
 
Selenium ppt
Selenium pptSelenium ppt
Selenium ppt
Aneesh Rangarajan
 
Web Test Automation with Selenium
Web Test Automation with SeleniumWeb Test Automation with Selenium
Web Test Automation with Selenium
vivek_prahlad
 
Test automation using selenium
Test automation using seleniumTest automation using selenium
Test automation using selenium
Cynoteck Technology Solutions Private Limited
 
Selenium WebDriver training
Selenium WebDriver trainingSelenium WebDriver training
Selenium WebDriver training
Vijay Krishnan Ramaswamy
 
SELENIUM PPT.pdf
SELENIUM PPT.pdfSELENIUM PPT.pdf
SELENIUM PPT.pdf
RebelSnowball
 
Selenium Interview Questions and Answers For Freshers And Experienced | Edureka
Selenium Interview Questions and Answers For Freshers And Experienced | EdurekaSelenium Interview Questions and Answers For Freshers And Experienced | Edureka
Selenium Interview Questions and Answers For Freshers And Experienced | Edureka
Edureka!
 

What's hot (20)

Selenium
SeleniumSelenium
Selenium
 
An overview of selenium webdriver
An overview of selenium webdriverAn overview of selenium webdriver
An overview of selenium webdriver
 
Selenium Presentation at Engineering Colleges
Selenium Presentation at Engineering CollegesSelenium Presentation at Engineering Colleges
Selenium Presentation at Engineering Colleges
 
Introduction to Selenium Web Driver
Introduction to Selenium Web DriverIntroduction to Selenium Web Driver
Introduction to Selenium Web Driver
 
Automation Testing using Selenium Webdriver
Automation Testing using Selenium WebdriverAutomation Testing using Selenium Webdriver
Automation Testing using Selenium Webdriver
 
Selenium WebDriver Tutorial | Selenium WebDriver Tutorial For Beginner | Sele...
Selenium WebDriver Tutorial | Selenium WebDriver Tutorial For Beginner | Sele...Selenium WebDriver Tutorial | Selenium WebDriver Tutorial For Beginner | Sele...
Selenium WebDriver Tutorial | Selenium WebDriver Tutorial For Beginner | Sele...
 
Selenium WebDriver
Selenium WebDriverSelenium WebDriver
Selenium WebDriver
 
Selenium ppt
Selenium pptSelenium ppt
Selenium ppt
 
Selenium- A Software Testing Tool
Selenium- A Software Testing ToolSelenium- A Software Testing Tool
Selenium- A Software Testing Tool
 
QSpiders - Automation using Selenium
QSpiders - Automation using SeleniumQSpiders - Automation using Selenium
QSpiders - Automation using Selenium
 
Automation Testing using Selenium
Automation Testing using SeleniumAutomation Testing using Selenium
Automation Testing using Selenium
 
Selenium Tutorial For Beginners | Selenium Automation Testing Tutorial | Sele...
Selenium Tutorial For Beginners | Selenium Automation Testing Tutorial | Sele...Selenium Tutorial For Beginners | Selenium Automation Testing Tutorial | Sele...
Selenium Tutorial For Beginners | Selenium Automation Testing Tutorial | Sele...
 
Automated Web Testing Using Selenium
Automated Web Testing Using SeleniumAutomated Web Testing Using Selenium
Automated Web Testing Using Selenium
 
Selenium IDE Tutorial For Beginners | Selenium IDE Tutorial | What Is Seleniu...
Selenium IDE Tutorial For Beginners | Selenium IDE Tutorial | What Is Seleniu...Selenium IDE Tutorial For Beginners | Selenium IDE Tutorial | What Is Seleniu...
Selenium IDE Tutorial For Beginners | Selenium IDE Tutorial | What Is Seleniu...
 
Selenium ppt
Selenium pptSelenium ppt
Selenium ppt
 
Web Test Automation with Selenium
Web Test Automation with SeleniumWeb Test Automation with Selenium
Web Test Automation with Selenium
 
Test automation using selenium
Test automation using seleniumTest automation using selenium
Test automation using selenium
 
Selenium WebDriver training
Selenium WebDriver trainingSelenium WebDriver training
Selenium WebDriver training
 
SELENIUM PPT.pdf
SELENIUM PPT.pdfSELENIUM PPT.pdf
SELENIUM PPT.pdf
 
Selenium Interview Questions and Answers For Freshers And Experienced | Edureka
Selenium Interview Questions and Answers For Freshers And Experienced | EdurekaSelenium Interview Questions and Answers For Freshers And Experienced | Edureka
Selenium Interview Questions and Answers For Freshers And Experienced | Edureka
 

Similar to Automation Testing by Selenium Web Driver

Automatedtestingwithselenium shubham jain
Automatedtestingwithselenium shubham jainAutomatedtestingwithselenium shubham jain
Automatedtestingwithselenium shubham jain
Prashant Gurav
 
Automated testing with selenium prasad bapatla
Automated testing with selenium prasad bapatlaAutomated testing with selenium prasad bapatla
Automated testing with selenium prasad bapatla
prasadbcs
 
How to use selenium locators effectively for web automation.pdf
How to use selenium locators effectively for web automation.pdfHow to use selenium locators effectively for web automation.pdf
How to use selenium locators effectively for web automation.pdf
pcloudy2
 
Selenium Interview Questions And Answers | Selenium Interview Questions | Sel...
Selenium Interview Questions And Answers | Selenium Interview Questions | Sel...Selenium Interview Questions And Answers | Selenium Interview Questions | Sel...
Selenium Interview Questions And Answers | Selenium Interview Questions | Sel...
Simplilearn
 
Selenium Overview
Selenium OverviewSelenium Overview
Selenium Overview
Abhijeet Vaikar
 
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
Ajit Jadhav
 
Selenium and The Grinder
Selenium and The GrinderSelenium and The Grinder
Selenium and The Grinder
OpenSource Connections
 
Selenium training
Selenium trainingSelenium training
Selenium training
Shivaraj R
 
Mastering Test Automation: How To Use Selenium Successfully
Mastering Test Automation: How To Use Selenium SuccessfullyMastering Test Automation: How To Use Selenium Successfully
Mastering Test Automation: How To Use Selenium Successfully
SpringPeople
 
Selenium corporate-training-in-mumbai
Selenium corporate-training-in-mumbaiSelenium corporate-training-in-mumbai
Selenium corporate-training-in-mumbai
vibrantuser
 
Selenium corporate-training-in-mumbai
Selenium corporate-training-in-mumbaiSelenium corporate-training-in-mumbai
Selenium corporate-training-in-mumbai
vibrantuser
 
Selenium with testng and eclipse ide
Selenium with testng and eclipse ideSelenium with testng and eclipse ide
Selenium with testng and eclipse ide
Testertester Jaipur
 
Selenium Webdriver Interview Questions
Selenium Webdriver Interview QuestionsSelenium Webdriver Interview Questions
Selenium Webdriver Interview Questions
Jai Singh
 
Object identification and its management
Object identification and its managementObject identification and its management
Object identification and its management
Vinay Kumar Pulabaigari
 
Selenium
SeleniumSelenium
Selenium
eduquer
 
Using XPath in Selenium_ All you need to know.pdf
Using XPath in Selenium_ All you need to know.pdfUsing XPath in Selenium_ All you need to know.pdf
Using XPath in Selenium_ All you need to know.pdf
RobertMartin69776
 
Selenium interview-questions-freshers
Selenium interview-questions-freshersSelenium interview-questions-freshers
Selenium interview-questions-freshers
Naga Mani
 
DevLabs Alliance Top 50 Selenium Interview Questions for SDET
DevLabs Alliance Top 50 Selenium Interview Questions for SDETDevLabs Alliance Top 50 Selenium Interview Questions for SDET
DevLabs Alliance Top 50 Selenium Interview Questions for SDET
DevLabs Alliance
 
DevLabs Alliance Top 50 Selenium Interview Questions for SDET
DevLabs Alliance Top 50 Selenium Interview Questions for SDETDevLabs Alliance Top 50 Selenium Interview Questions for SDET
DevLabs Alliance Top 50 Selenium Interview Questions for SDET
DevLabs Alliance
 
Dev labs alliance top 50 selenium interview questions for SDET
Dev labs alliance top 50 selenium interview questions for SDETDev labs alliance top 50 selenium interview questions for SDET
Dev labs alliance top 50 selenium interview questions for SDET
devlabsalliance
 

Similar to Automation Testing by Selenium Web Driver (20)

Automatedtestingwithselenium shubham jain
Automatedtestingwithselenium shubham jainAutomatedtestingwithselenium shubham jain
Automatedtestingwithselenium shubham jain
 
Automated testing with selenium prasad bapatla
Automated testing with selenium prasad bapatlaAutomated testing with selenium prasad bapatla
Automated testing with selenium prasad bapatla
 
How to use selenium locators effectively for web automation.pdf
How to use selenium locators effectively for web automation.pdfHow to use selenium locators effectively for web automation.pdf
How to use selenium locators effectively for web automation.pdf
 
Selenium Interview Questions And Answers | Selenium Interview Questions | Sel...
Selenium Interview Questions And Answers | Selenium Interview Questions | Sel...Selenium Interview Questions And Answers | Selenium Interview Questions | Sel...
Selenium Interview Questions And Answers | Selenium Interview Questions | Sel...
 
Selenium Overview
Selenium OverviewSelenium Overview
Selenium Overview
 
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
 
Selenium and The Grinder
Selenium and The GrinderSelenium and The Grinder
Selenium and The Grinder
 
Selenium training
Selenium trainingSelenium training
Selenium training
 
Mastering Test Automation: How To Use Selenium Successfully
Mastering Test Automation: How To Use Selenium SuccessfullyMastering Test Automation: How To Use Selenium Successfully
Mastering Test Automation: How To Use Selenium Successfully
 
Selenium corporate-training-in-mumbai
Selenium corporate-training-in-mumbaiSelenium corporate-training-in-mumbai
Selenium corporate-training-in-mumbai
 
Selenium corporate-training-in-mumbai
Selenium corporate-training-in-mumbaiSelenium corporate-training-in-mumbai
Selenium corporate-training-in-mumbai
 
Selenium with testng and eclipse ide
Selenium with testng and eclipse ideSelenium with testng and eclipse ide
Selenium with testng and eclipse ide
 
Selenium Webdriver Interview Questions
Selenium Webdriver Interview QuestionsSelenium Webdriver Interview Questions
Selenium Webdriver Interview Questions
 
Object identification and its management
Object identification and its managementObject identification and its management
Object identification and its management
 
Selenium
SeleniumSelenium
Selenium
 
Using XPath in Selenium_ All you need to know.pdf
Using XPath in Selenium_ All you need to know.pdfUsing XPath in Selenium_ All you need to know.pdf
Using XPath in Selenium_ All you need to know.pdf
 
Selenium interview-questions-freshers
Selenium interview-questions-freshersSelenium interview-questions-freshers
Selenium interview-questions-freshers
 
DevLabs Alliance Top 50 Selenium Interview Questions for SDET
DevLabs Alliance Top 50 Selenium Interview Questions for SDETDevLabs Alliance Top 50 Selenium Interview Questions for SDET
DevLabs Alliance Top 50 Selenium Interview Questions for SDET
 
DevLabs Alliance Top 50 Selenium Interview Questions for SDET
DevLabs Alliance Top 50 Selenium Interview Questions for SDETDevLabs Alliance Top 50 Selenium Interview Questions for SDET
DevLabs Alliance Top 50 Selenium Interview Questions for SDET
 
Dev labs alliance top 50 selenium interview questions for SDET
Dev labs alliance top 50 selenium interview questions for SDETDev labs alliance top 50 selenium interview questions for SDET
Dev labs alliance top 50 selenium interview questions for SDET
 

More from Cuelogic Technologies Pvt. Ltd.

Big data frameworks
Big data frameworksBig data frameworks
Big data frameworks
Cuelogic Technologies Pvt. Ltd.
 
Introduction to mongoDB
Introduction to mongoDBIntroduction to mongoDB
Introduction to mongoDB
Cuelogic Technologies Pvt. Ltd.
 
Introduction to google glass and GDK
Introduction to google glass and GDKIntroduction to google glass and GDK
Introduction to google glass and GDK
Cuelogic Technologies Pvt. Ltd.
 
Trends in mobile applications development
Trends in mobile applications developmentTrends in mobile applications development
Trends in mobile applications development
Cuelogic Technologies Pvt. Ltd.
 
HTML5
HTML5HTML5
How to begin with Amazon EC2?
How to begin with Amazon EC2?How to begin with Amazon EC2?
How to begin with Amazon EC2?
Cuelogic Technologies Pvt. Ltd.
 

More from Cuelogic Technologies Pvt. Ltd. (6)

Big data frameworks
Big data frameworksBig data frameworks
Big data frameworks
 
Introduction to mongoDB
Introduction to mongoDBIntroduction to mongoDB
Introduction to mongoDB
 
Introduction to google glass and GDK
Introduction to google glass and GDKIntroduction to google glass and GDK
Introduction to google glass and GDK
 
Trends in mobile applications development
Trends in mobile applications developmentTrends in mobile applications development
Trends in mobile applications development
 
HTML5
HTML5HTML5
HTML5
 
How to begin with Amazon EC2?
How to begin with Amazon EC2?How to begin with Amazon EC2?
How to begin with Amazon EC2?
 

Recently uploaded

Advanced Techniques for Cyber Security Analysis and Anomaly Detection
Advanced Techniques for Cyber Security Analysis and Anomaly DetectionAdvanced Techniques for Cyber Security Analysis and Anomaly Detection
Advanced Techniques for Cyber Security Analysis and Anomaly Detection
Bert Blevins
 
RPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptx
RPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptxRPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptx
RPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptx
SynapseIndia
 
The Evolution of Remote Server Management
The Evolution of Remote Server ManagementThe Evolution of Remote Server Management
The Evolution of Remote Server Management
Bert Blevins
 
Data Integration Basics: Merging & Joining Data
Data Integration Basics: Merging & Joining DataData Integration Basics: Merging & Joining Data
Data Integration Basics: Merging & Joining Data
Safe Software
 
How Social Media Hackers Help You to See Your Wife's Message.pdf
How Social Media Hackers Help You to See Your Wife's Message.pdfHow Social Media Hackers Help You to See Your Wife's Message.pdf
How Social Media Hackers Help You to See Your Wife's Message.pdf
HackersList
 
Scaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - Mydbops
Scaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - MydbopsScaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - Mydbops
Scaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - Mydbops
Mydbops
 
find out more about the role of autonomous vehicles in facing global challenges
find out more about the role of autonomous vehicles in facing global challengesfind out more about the role of autonomous vehicles in facing global challenges
find out more about the role of autonomous vehicles in facing global challenges
huseindihon
 
High Profile Girls call Service Pune 000XX00000 Provide Best And Top Girl Ser...
High Profile Girls call Service Pune 000XX00000 Provide Best And Top Girl Ser...High Profile Girls call Service Pune 000XX00000 Provide Best And Top Girl Ser...
High Profile Girls call Service Pune 000XX00000 Provide Best And Top Girl Ser...
bhumivarma35300
 
Implementations of Fused Deposition Modeling in real world
Implementations of Fused Deposition Modeling  in real worldImplementations of Fused Deposition Modeling  in real world
Implementations of Fused Deposition Modeling in real world
Emerging Tech
 
“Deploying Large Language Models on a Raspberry Pi,” a Presentation from Usef...
“Deploying Large Language Models on a Raspberry Pi,” a Presentation from Usef...“Deploying Large Language Models on a Raspberry Pi,” a Presentation from Usef...
“Deploying Large Language Models on a Raspberry Pi,” a Presentation from Usef...
Edge AI and Vision Alliance
 
The Role of Technology in Payroll Statutory Compliance (1).pdf
The Role of Technology in Payroll Statutory Compliance (1).pdfThe Role of Technology in Payroll Statutory Compliance (1).pdf
The Role of Technology in Payroll Statutory Compliance (1).pdf
paysquare consultancy
 
Three New Criminal Laws in India 1 July 2024
Three New Criminal Laws in India 1 July 2024Three New Criminal Laws in India 1 July 2024
Three New Criminal Laws in India 1 July 2024
aakash malhotra
 
[Talk] Moving Beyond Spaghetti Infrastructure [AOTB] 2024-07-04.pdf
[Talk] Moving Beyond Spaghetti Infrastructure [AOTB] 2024-07-04.pdf[Talk] Moving Beyond Spaghetti Infrastructure [AOTB] 2024-07-04.pdf
[Talk] Moving Beyond Spaghetti Infrastructure [AOTB] 2024-07-04.pdf
Kief Morris
 
How to build a generative AI solution A step-by-step guide (2).pdf
How to build a generative AI solution A step-by-step guide (2).pdfHow to build a generative AI solution A step-by-step guide (2).pdf
How to build a generative AI solution A step-by-step guide (2).pdf
ChristopherTHyatt
 
Password Rotation in 2024 is still Relevant
Password Rotation in 2024 is still RelevantPassword Rotation in 2024 is still Relevant
Password Rotation in 2024 is still Relevant
Bert Blevins
 
Acumatica vs. Sage Intacct vs. NetSuite _ NOW CFO.pdf
Acumatica vs. Sage Intacct vs. NetSuite _ NOW CFO.pdfAcumatica vs. Sage Intacct vs. NetSuite _ NOW CFO.pdf
Acumatica vs. Sage Intacct vs. NetSuite _ NOW CFO.pdf
BrainSell Technologies
 
IPLOOK Remote-Sensing Satellite Solution
IPLOOK Remote-Sensing Satellite SolutionIPLOOK Remote-Sensing Satellite Solution
IPLOOK Remote-Sensing Satellite Solution
IPLOOK Networks
 
Litestack talk at Brighton 2024 (Unleashing the power of SQLite for Ruby apps)
Litestack talk at Brighton 2024 (Unleashing the power of SQLite for Ruby apps)Litestack talk at Brighton 2024 (Unleashing the power of SQLite for Ruby apps)
Litestack talk at Brighton 2024 (Unleashing the power of SQLite for Ruby apps)
Muhammad Ali
 
Active Inference is a veryyyyyyyyyyyyyyyyyyyyyyyy
Active Inference is a veryyyyyyyyyyyyyyyyyyyyyyyyActive Inference is a veryyyyyyyyyyyyyyyyyyyyyyyy
Active Inference is a veryyyyyyyyyyyyyyyyyyyyyyyy
RaminGhanbari2
 
Salesforce AI & Einstein Copilot Workshop
Salesforce AI & Einstein Copilot WorkshopSalesforce AI & Einstein Copilot Workshop
Salesforce AI & Einstein Copilot Workshop
CEPTES Software Inc
 

Recently uploaded (20)

Advanced Techniques for Cyber Security Analysis and Anomaly Detection
Advanced Techniques for Cyber Security Analysis and Anomaly DetectionAdvanced Techniques for Cyber Security Analysis and Anomaly Detection
Advanced Techniques for Cyber Security Analysis and Anomaly Detection
 
RPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptx
RPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptxRPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptx
RPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptx
 
The Evolution of Remote Server Management
The Evolution of Remote Server ManagementThe Evolution of Remote Server Management
The Evolution of Remote Server Management
 
Data Integration Basics: Merging & Joining Data
Data Integration Basics: Merging & Joining DataData Integration Basics: Merging & Joining Data
Data Integration Basics: Merging & Joining Data
 
How Social Media Hackers Help You to See Your Wife's Message.pdf
How Social Media Hackers Help You to See Your Wife's Message.pdfHow Social Media Hackers Help You to See Your Wife's Message.pdf
How Social Media Hackers Help You to See Your Wife's Message.pdf
 
Scaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - Mydbops
Scaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - MydbopsScaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - Mydbops
Scaling Connections in PostgreSQL Postgres Bangalore(PGBLR) Meetup-2 - Mydbops
 
find out more about the role of autonomous vehicles in facing global challenges
find out more about the role of autonomous vehicles in facing global challengesfind out more about the role of autonomous vehicles in facing global challenges
find out more about the role of autonomous vehicles in facing global challenges
 
High Profile Girls call Service Pune 000XX00000 Provide Best And Top Girl Ser...
High Profile Girls call Service Pune 000XX00000 Provide Best And Top Girl Ser...High Profile Girls call Service Pune 000XX00000 Provide Best And Top Girl Ser...
High Profile Girls call Service Pune 000XX00000 Provide Best And Top Girl Ser...
 
Implementations of Fused Deposition Modeling in real world
Implementations of Fused Deposition Modeling  in real worldImplementations of Fused Deposition Modeling  in real world
Implementations of Fused Deposition Modeling in real world
 
“Deploying Large Language Models on a Raspberry Pi,” a Presentation from Usef...
“Deploying Large Language Models on a Raspberry Pi,” a Presentation from Usef...“Deploying Large Language Models on a Raspberry Pi,” a Presentation from Usef...
“Deploying Large Language Models on a Raspberry Pi,” a Presentation from Usef...
 
The Role of Technology in Payroll Statutory Compliance (1).pdf
The Role of Technology in Payroll Statutory Compliance (1).pdfThe Role of Technology in Payroll Statutory Compliance (1).pdf
The Role of Technology in Payroll Statutory Compliance (1).pdf
 
Three New Criminal Laws in India 1 July 2024
Three New Criminal Laws in India 1 July 2024Three New Criminal Laws in India 1 July 2024
Three New Criminal Laws in India 1 July 2024
 
[Talk] Moving Beyond Spaghetti Infrastructure [AOTB] 2024-07-04.pdf
[Talk] Moving Beyond Spaghetti Infrastructure [AOTB] 2024-07-04.pdf[Talk] Moving Beyond Spaghetti Infrastructure [AOTB] 2024-07-04.pdf
[Talk] Moving Beyond Spaghetti Infrastructure [AOTB] 2024-07-04.pdf
 
How to build a generative AI solution A step-by-step guide (2).pdf
How to build a generative AI solution A step-by-step guide (2).pdfHow to build a generative AI solution A step-by-step guide (2).pdf
How to build a generative AI solution A step-by-step guide (2).pdf
 
Password Rotation in 2024 is still Relevant
Password Rotation in 2024 is still RelevantPassword Rotation in 2024 is still Relevant
Password Rotation in 2024 is still Relevant
 
Acumatica vs. Sage Intacct vs. NetSuite _ NOW CFO.pdf
Acumatica vs. Sage Intacct vs. NetSuite _ NOW CFO.pdfAcumatica vs. Sage Intacct vs. NetSuite _ NOW CFO.pdf
Acumatica vs. Sage Intacct vs. NetSuite _ NOW CFO.pdf
 
IPLOOK Remote-Sensing Satellite Solution
IPLOOK Remote-Sensing Satellite SolutionIPLOOK Remote-Sensing Satellite Solution
IPLOOK Remote-Sensing Satellite Solution
 
Litestack talk at Brighton 2024 (Unleashing the power of SQLite for Ruby apps)
Litestack talk at Brighton 2024 (Unleashing the power of SQLite for Ruby apps)Litestack talk at Brighton 2024 (Unleashing the power of SQLite for Ruby apps)
Litestack talk at Brighton 2024 (Unleashing the power of SQLite for Ruby apps)
 
Active Inference is a veryyyyyyyyyyyyyyyyyyyyyyyy
Active Inference is a veryyyyyyyyyyyyyyyyyyyyyyyyActive Inference is a veryyyyyyyyyyyyyyyyyyyyyyyy
Active Inference is a veryyyyyyyyyyyyyyyyyyyyyyyy
 
Salesforce AI & Einstein Copilot Workshop
Salesforce AI & Einstein Copilot WorkshopSalesforce AI & Einstein Copilot Workshop
Salesforce AI & Einstein Copilot Workshop
 

Automation Testing by Selenium Web Driver

  • 1. Automation Testing by Selenium Web Driver As efficient as your in-house team We provide the people, the ability and the tools so you can be best at what you do.
  • 3. Why automate testing? Test automation has specific advantages for improving the long-term efficiency of a software team’s testing processes. Test automation supports: 0 Frequent regression testing 0 Rapid feedback to developers 0 Virtually unlimited iterations of test case execution 0 Support for Agile and extreme development methodologies 0 Disciplined documentation of test cases 0 Customized defect reporting 0 Finding defects missed by manual testing
  • 5. Selenium History 0 2004 - at ThoughtWorks in Chicago, Jason Huggins built the Core mode as "JavaScriptTestRunner" for the testing of an internal Time and Expenses application (Python, Plone). 0 2006 - at Google, Simon Stewart started work on a project he called WebDriver. Google had long been a heavy user of Selenium, but testers had to work around the limitations of the product. The WebDriver project began with the aim to solve the Selenium’ pain-points. 0 2008 - merging of Selenium and WebDriver. Selenium had massive community and commercial support, but WebDriver was clearly the tool of the future. The joining of the two tools provided a common set of features for all users and brought some of the brightest minds in test automation under one roof. 0 Shinya Kasatani in Japan became interested in Selenium, he 0 Wrapped the core code into an IDE module into the Firefox browser 0 Added the ability to record tests as well as play them back in the same plugin. 0 This tool, turned out an eye opener in more ways that was originally thought as it is not bound to the same origin policy. 0 See http://docs.seleniumhq.org/about/history.jsp for more interesting details 0 http://docs.seleniumhq.org/about/contributors.jsp
  • 9. Script Syntax 0 Selenium scripts that will be run from Selenium-IDE are stored in an HTML text file format. 0 HTML table with three columns. 0 The first column identifies the Selenium command 0 the second is a target, and 0 the final column contains a value. 0 The second and third columns may not require values depending on the chosen Selenium command, but they should be present. 0 Each table row represents a new Selenium command.
  • 10. Commonly Used Selenium Commands  Open - opens a page using a URL.  click/clickAndWait - performs a click operation, and optionally waits for a new page to load.  verifyTitle/assertTitle - verifies an expected page title.  verifyTextPresent - verifies expected text is somewhere on the page.  verifyElementPresent - verifies an expected UI element, as defined by its HTML tag, is present on the page.  verifyText - verifies expected text and its corresponding HTML tag are present on the page.  verifyTable - verifies a table’s expected contents.  waitForPageToLoad - pauses execution until an expected new page loads. Called automatically when clickAndWait is used.  waitForElementPresent - pauses execution until an expected UI element, as defined by its HTML tag, is present on the page.
  • 11. Locating Elements 0 For many Selenium commands, a target is required. This target identifies an element in the content of the web application, and consists of the location strategy followed by the location in the format locatorType=location 0 Locating by Identifier : the most common method of locating elements and is the catch-all default when no recognized locator type is used 0 the first element with the id attribute value matching the location will be used. If no element has a matching id attribute, then the first element with a name attribute matching the location will be used
  • 12. Locating Elements 0 Locating by Id: more limited than the identifier locator type, but also more explicit. 0 Use this when you know an element’s id attribute. 0 Locating by Name: will locate the first element with a matching name attribute. If multiple elements have the same value for a name attribute, then you can use filters to further refine your location strategy. 0 The default filter type is value (matching the value attribute).
  • 13. Locating Elements 0 Locating by Xpath : XPath extends beyond (as well as supporting) the simple methods of locating by id or name attributes, and opens up all sorts of new possibilities such as locating the third checkbox on the page. 0 Since only xpath locators start with “//”, it is not necessary to include the xpath= label when specifying an XPath locator. 0 Absolute XPaths contain the location of all elements from the root (html) and as a result are likely to fail with only the slightest adjustment to the application. By finding a nearby element with an id or name attribute (ideally a parent element) you can locate your target element based on the relationship. This is much less likely to change and can make your tests more robust.
  • 14. Locating Elements 0 Locating Hyperlinks by Link Text: simple method of locating a hyperlink in your web page by using the text of the link. If two links with the same text are present, then the first match will be used. 0 Locating by CSS: CSS uses Selectors for binding style properties to elements in the document. These Selectors can be used by Selenium as another locating strategy. 0 Most experienced Selenium users recommend CSS as their locating strategy of choice as it’s considerably faster than XPath and can find the most complicated objects in an intrinsic HTML document.
  • 15. Matching Text Patterns 0 Like locators, patterns are a type of parameter frequently required by Selenese commands. 0 Examples of commands which require patterns are 0 verifyTextPresent, 0 verifyTitle, 0 verifyAlert, 0 assertConfirmation, 0 verifyText, and 0 verifyPrompt. 0 link locators can utilize a pattern. 0 Patterns allow you to describe, via the use of special characters, what text is expected rather than having to specify that text exactly.
  • 18. Save Test Case Script as HTML
  • 23. Xpath by Xpath Checker Xpath is a very Helpful to validate Xpath on pages. In order to write xpath expressions we should look at the tree structure of html source code and based On the path for require element we should drive the xpath expression.
  • 24. /html/body/a - It will Identify all the elements are using a tag. /html/body/input - It will Identify all the elements are using input tag. /html/body/input[1] – It will Identify the first input tag under body. /html/body/a/img – xpath for a image present on a link. /html/body/table/tbody/tr[2]/td[1] – It will Identify the element which is present in 2nd tr contain 1st td inside tbody. /html/body/div//a – It will identify all “a” tag present in the all div present on html body.
  • 25. Generally we use xpath by position along with xpath by attribute. Ex- /html/body/input[@id=‘UN’] //input[@value=‘login’] //a[@href=‘http://www.cuelogic.com/’] //a[text()=‘Cuelogic’] – This xpath will identify the element by text “Cuelogic” //a[contains[text(), ‘Cuelogic’]] – This xpath will also identify the element by text “Cuelogic” but if their any spaces at beginning or at end it will consider it. //td[a] - “[ ]” denotes select all while “/” denote as parent to element path ignore all other elements in tree same Structure. Htmltag[@PN=‘PV’]
  • 26. Identify the Dependent and Independent Elements- Derived xpath expression for the dependent element from the common parent //tr[td[a[text()=‘Cuelogic’]]]/td[3]/input Write a xpath for independent element – //a[text()=‘Cuelogic’]
  • 28. Edit Script and find element by xpath
  • 31. A few tips 0 Saving a test suite does not save the test case. 0 Make sure that you save the test case every time you make a change and not just the test suite. 0 echo - The Selenese Print Command 0 Use Find button to see which UI element on the currently displayed webpage (in the browser) is used in the currently selected Selenium command. This is useful when building a locator for a command’s first parameter
  • 32. Selenium IDE – Limitations/Drawbacks 0 Firefox only 0 Can not Specify any condition Statement. 0 Can not Specify any Looping Statement. 0 Can not take external text data from External Resources such as XLS,XML or Database. 0 Handing Exceptions is not in scope. 0 Note:- To overcome the limitation of Selenium IDE we go for Selenium WebDriver.
  • 33. Selenium Web Driver 0 WebDriver is a tool for automating web application testing, and in particular to verify that they work as expected. 0 It aims to provide a friendly API that’s easy to explore and understand, easier to use than the Selenium-RC (1.0) API, which will help to make your tests easier to read and maintain. 0 It’s not tied to any particular test framework, so it can be used equally well in a unit testing or from a plain old “main” method.
  • 34. Selenium Web Driver – Browser Support Selenium-WebDriver supports the following browsers along with the operating systems these browsers are compatible with. 0 Google Chrome 0 Internet Explorer 0 Firefox 0 Opera 11.5+ 0 HtmlUnit 0 Android – 2.3+ for phones and tablets (devices & emulators) 0 iOS 3+ for phones (devices & emulators) and 3.2+ for tablets (devices & emulators)
  • 35. WebDriver & Selenium-Server Some reasons to use the Selenium-Server with Selenium-WebDriver. 0 You are using Selenium-Grid to distribute your tests over multiple machines or virtual machines (VMs). 0 You want to connect to a remote machine that has a particular browser version that is not on your current machine. 0 You are not using the Java bindings (i.e. Python, C#, or Ruby) and would like to use HtmlUnit Driver
  • 40. Simple Architecture of WebDriver WEBDRIVER(i) Remote Webdriver Firefox Driver Chrome Driver Internet Explorer Driver Interface Protected class
  • 42. Browser open by Webdriver.
  • 43. Methods:- “findElement” is a method of webdriver interface which is Use to identify required element in the application. This method takes an Object as an argument of type “By”. Locators:- Webdriver supports 8 types of locators to identify the Elements and all the locators will return the object of the type Webelements. Types of Locators:- 1. By.id(arg) 2. By.name(String) 3. By.xpath(String xpathExpression) 4. By.cssSelector(String Selector) 5. By.linkText(String linkText) 6. By.partialLinkText(String linkText) 7. By.className(String className) 8. By.tagName(String Name)
  • 46. Retrieving the value from application While doing validation we compare excepted result and actual result then we will report the status. Actual result will be taken from application during runtime. In order to do this we use following important Method. 1. getTitle() :- This method help us to retrieve the title of the webpage. 2. GetcurrentUrl():- This method will retrieve the current url from the address bar of the browser. 3. getAttribute(“value”) :- This is used to retrieve property value from the element present in the application. It is basically used to retrieve text from Textbox, password field, Address Field, Path of uploading file and button name. 4. isEnable() :- This method is used to check whether the specify elements enable or not. True indicates enable and false indicates disable. 5. isSelected() :- It is used to checked whether the specific checkbox or radio button is selected or not. 6. getText():- It is used to retrieve the text of the following element.
  • 48. Browser Operations 1. Navigate back to Previous Page:- driver.navigate().back(); 2. Navigate to the next Page:- driver.navigate().forward(); 3. Refresh Mehods :- driver.navigate().refresh(); Handling Frames
  • 49. Q: How do I execute Javascript directly? A: WebDriver driver; // Assigned elsewhere JavascriptExecutor js = (JavascriptExecutor) driver; js.executeScript("return document.title"); Q: The InternetExplorerDriver does not work well on Vista. How do I get it to work as expected? A:DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer(); capabilities.setCapability(InternetExplorerDriver. INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true); WebDriver driver = new InternetExplorerDriver(capabilities); Q: Does WebDriver support Javascript alerts and prompts? A: // Get a handle to the open alert, prompt or confirmation Alert alert = driver.switchTo().alert(); // Get the text of the alert or prompt alert.getText(); // And acknowledge the alert (equivalent to clicking "OK") alert.accept(); //And to decline alert Alert.dismiss();
  • 50. Q: I need to use a proxy. How do I configure that? A: Proxy configuration is done via the org.openqa.selenium.Proxy class like so: Proxy proxy = new Proxy(); proxy.setProxyAutoconfigUrl("http://youdomain/config"); // We use firefox as an example here. DesiredCapabilities capabilities = DesiredCapabilities.firefox(); capabilities.setCapability(CapabilityType.PROXY, proxy); // You could use any webdriver implementation here WebDriver driver = new FirefoxDriver(capabilities); Q: WebDriver fails to start Firefox on Linux due to java.net.SocketException A: If, when running WebDriver on Linux, Firefox fails to start and the error looks like: Caused by: java.net.SocketException: Invalid argument at java.net.PlainSocketImpl.socketBind(Native Method) at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:365) at java.net.Socket.bind(Socket.java:571) at org.openqa.selenium.firefox.internal.SocketLock.isLockFree(SocketLock.java:99) at org.openqa.selenium.firefox.internal.SocketLock.lock(SocketLock.java:63) It may be caused due to IPv6 settings on the machine. Execute: sudo sysctl net.ipv6.bindv6only=0
  • 51. Framework Execution Flow Keyword driver automation framework:-
  • 53. Selenium RC Selenium RC comes in two parts. A server which automatically launches and kills browsers, and acts as a HTTP proxy for web requests from them. Client libraries for your favorite computer language.
  • 54. References 0 http://docs.seleniumhq.org/ 0 Selenium and Section 508 by David Sills 0 http://java.dzone.com/articles/selenium-and-section-508 0 Selenium Tutorial for Beginner/Tips for Experts 0 http://www.jroller.com/selenium/ 0 Get Test-Infected With Selenium 0 http://net.tutsplus.com/tutorials/tools-and-tips/get-test- infected-with-selenium-2/ 0 https://code.google.com/p/selenium/
  • 55. Books
  • 56. Thanks & enjoy the rest of the code camp 