SlideShare a Scribd company logo
1 of 31
Quality Assurance /
Software Testing Training
Page 2Classification: Restricted
Agenda
• Overview of Selenium WebDriver
• Get Selenium WebDriver Java
• Selenium – JAVA Configuration
• WebDriver in Different Browsers
• Open Application
• Browser Settings
• Locating Elements
• Object Identification Methods
• Locator ID, Name
• Locators –LinkText, partialLinkText, CSS, CSS
• Accessing different objects in application
• Switch Window
• Wait in WebDriver
• Verifications
• WebTable
Page 3Classification: Restricted
• Selenium WebDriver - is latest version of Selenium (Selenium 2/3)
• WebDriver is a compact Object Oriented API when compared to
Selenium1.0
• It drives the browser much more effectively
• WebDriver will support following programming languages
• Java, C#, Ruby, Python, JavaScript (Node.js)
• Selenium WebDriver will support following browsers
• Google Chrome, Internet Explorer, Firefox, Safari, Opera, Edge
(Win 10)
Overview of Selenium WebDriver
Page 4Classification: Restricted
• Selenium WebDriver is available from Selenium official website
(http://www.seleniumhq.org)
• It is an open source and free software
• Source code is available in
https://github.com/SeleniumHQ/selenium
Get Selenium WebDriver Java
Page 5Classification: Restricted
• Install Java JDK (1.8 is recommended)
• Install Java IDE (Eclipse Kepler)
• Download Selenium Java jar files
(http://www.seleniumhq.org/download/)
• Install and configure browsers in the system
• Download required browser driver
Selenium – JAVA configuration
Page 6Classification: Restricted
• Open Eclipse with Workspace
• Create a new Java project (As
mentioned in the Core Java
session)
• Right click on the project and go
to Build Path -> Configure Build
Path
Selenium – JAVA Project creation
Page 7Classification: Restricted
Selenium – JAVA Project creation
7
• Go to Libraries Tab and click on Add External Jars… to select selenium Jar
files
• Select all jars which are download then click on Open and click on OK
Page 8Classification: Restricted
WebDriver in Different Browsers
8
• Google Chrome
• Mozilla Firefox
• MS Internet Explorer
• Safari
WebDriver driver;
System.setProperty("webdriver.chrome.driver", “<<Path of
chromedriver.exe>>");
driver = new ChromeDriver();
System.setProperty("webdriver.gecko.driver", “<<path of
geckodriver.exe>>");
driver = new FirefoxDriver();
System.setProperty(“webdriver.ie.driver ",“<<Path of
IEDriverServer.exe>>");
driver = new InternetExplorerDriver();
driver = new SafariDriver();
Page 9Classification: Restricted
• MS Edge(Windows 10)
System.setProperty("webdriver.edge.driver", “<<path of
MicrosoftWebDriver.exe“>>);
driver = new EdgeDriver();
WebDriver in Different Browsers
Page 10Classification: Restricted
• Pre-requisites to open a URL
• Browser need to be installed
• Browser driver need to upgrade based on browser version
• Browser zoom level should be 100%
• Syntax to open url is,
driver.get(“http://google.com/”);
Open Application
Page 11Classification: Restricted
• For Internet Explorer,
• On IE 7 or higher on Windows, must set the Protected Mode
settings for each zone to be the same value.
• The value can be on or off, as long as it is the same for every
zone.
Browser Settings
Page 12Classification: Restricted
• To set the Protected Mode settings,
choose "Internet Options..." from
the Tools menu, and click on the
Security tab.
• For each zone, there will be a check
box at the bottom of the tab
labeled "Enable Protected Mode"
Browser Settings
Page 13Classification: Restricted
• Locating elements in WebDriver is done by using the
findElement(By.locator()) method
Variati
on
Description Sample
By.id
locates elements by the
value of their "id" attribute
findElement(By.id("someId
"))
By.nam
e
locates elements by the
value of the "name"
attribute
findElement(By.name("so
meName"))
By.linkT
ext
finds a link element by the
exact text it displays
findElement(By.linkText("R
EGISTRATION"))
By.parti
alLinkTe
xt
locates elements that
contain the given link text
findElement(By.partialLink
Text("REG"))
By.cssS
elector
finds elements based on the
driver's underlying CSS
Selector engine
findElement(By.cssSelector
("input#email"))
Locating Elements
Page 14Classification: Restricted
Variati
on
Description Sample
By.class
Name
finds elements based on the
value of the "class" attribute
findElement(By.className
("someClassName"))
By.tagN
ame
locates elements by their tag
name
findElement(By.tagName("
div"))
By.xpat
h
locates elements via XPath
findElement(By.xpath(“//in
put[@id=‘username’]"))
Locating Elements
Page 15Classification: Restricted
IE Developer tool:
• Press F12 to open developer tool
• Click on the arrow key to select the object to get the property
• Click on Attribute to get different object attributes
Object Identification Methods
Page 16Classification: Restricted
Chrome: Inspect element
• Right click on the object you want identify and select Inspect element
option
• Find different properties available with the object or right click on
highlighted code and select copy CSS path or Copy Xpath
Object Identification Methods
Page 17Classification: Restricted
Firefox: Inspect element
• Right click on the object you want identify and select Inspect element
(Q) option
• Find different properties available with the object
Firebug (Firefox add-on)
• Firebug has different methods to select the object properties
• Find for the code
• Select properties for DOM
• Copy Xpath
• Copy CSS file
Object Identification Methods
Page 18Classification: Restricted
Selenium IDE
• Enter the object property Target column and click on Find button to
check the object
• Click on Select and highlight the object to get the object properties
Object Identification Methods
Page 19Classification: Restricted
The Id strategy looks for an element in the page having an id attribute
corresponding to the specified pattern. <label id="my_id" /> will be matched
by a locator like id=my_id or just my_id
driver.findElement(By.id("my_id"));
Locator ID
Page 20Classification: Restricted
Is the Id strategy, but on the name attribute
<html>
<body>
<div id="pancakes">
<button type="button" name="pancake“
value="Blueberry">Blueberry</button>
</div>
</body>
</html>
driver.findElement(By.name("pancake"));
Locator Name
Page 21Classification: Restricted
select links only and selects the anchor element containing the specified
text: link=The text of the link
<a href="http://www.phptravels.net/offers.html" target="_self">
Offers</a>
driver.findElement(By.linkText("Offers"));
Locators -LinkText
Page 22Classification: Restricted
 select links only and selects the anchor element containing the
specified text: link=The text of the link and take the part of the link
 <a
href="mercuryunderconst.php?osCsid=af0ce02d7eb466b9a4ec43f
2d5273db9">Car Rentals</a>
driver.findElement(By.partialLinkText("Ren"));
Locators -partialLinkText
Page 23Classification: Restricted
 CSS Selectors are string patterns used to identify an element based
on a combination of HTML tag, id, class, and attributes. Locating by
CSS Selector is more complicated than the previous methods, but it
is the most common locating strategy of advanced Selenium users
because it can access even those elements that have no ID or
name.
driver.findElement(By.cssSelector("input #usernme"));
Locators -CSS
Page 24Classification: Restricted
 XPath is the standard navigation tool for XML; and an HTML
document is also an XML document (xHTML). XPath is used
everywhere where there is XML.
 It can access almost any element, even those without class, name,
or id attributes.
 It is the most complicated method of identifying elements because
of too many different rules and considerations.
driver.findElement(By.xpath("//input[@id = 'usernme']"));
Locators -Xpath
Page 25Classification: Restricted
 Dropdown, Multi select
 Declare the drop-down element
 Select elmDrp=new Select
(WebElement)
 elmDrp.selectByVisibleText(”text
”)
 deselectByVisibleText()
 selectByIndex()
 deselectByIndex()
 isMultiple()
 deselectAll()
 Text Fields
 .sendKeys(“value”)
 .clear()
 Radio button, Link
 .click()
 Checkbox
 .click()
 .isSelected()
Accessing Different Objects in Application
Page 26Classification: Restricted
 Switching Between Frames
 driver.switchTo().frame(“FrameName”)
 Switching Between Pop-up Windows
 driver.switchTo().alert()
 Get pop-up message
 driver.switchTo().alert().getText()
 Click on OK on pop-up
 driver.switchTo().alert().accept()
Switch Window
Page 27Classification: Restricted
 Implicit wait
 Used to set the default waiting time throughout the program
 driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
 Explicit wait
 used to set the waiting time for a particular instance only
 WebDriverWait wait = new WebDriverWait(driver,10);
 wait.until(ExpectedConditions.visibilityOfElementLocated(By.n
ame("userName")));
Wait in WebDriver
Page 28Classification: Restricted
 Check object exist
 driver.findElements(obj).size()
 driver.findElement(obj).isDisplayed()
 isEnabled()
 isDisplayed()
 isSelected()
 elementToBeClickable()
 frameToBeAvailableAndSwitchToIt()
Verifications
Page 29Classification: Restricted
 To get items from a table we can create object by table xpath
 To get value from different row and column create dynamic object
run time
 String xpath = "//table[@width="270"]/tbody/tr[" + row +
"]/td[" + col + "]";
 driver.findElement(By.xpath(xpath)).getText();
 Can create table xpath with some unique property
WebTable
Page 30Classification: Restricted
Question?
3
Page 31Classification: Restricted
Thank You

More Related Content

What's hot

Selenium Maven With Eclipse | Edureka
Selenium Maven With Eclipse | EdurekaSelenium Maven With Eclipse | Edureka
Selenium Maven With Eclipse | EdurekaEdureka!
 
Selenium- A Software Testing Tool
Selenium- A Software Testing ToolSelenium- A Software Testing Tool
Selenium- A Software Testing ToolZeba Tahseen
 
Test Automation and Selenium
Test Automation and SeleniumTest Automation and Selenium
Test Automation and SeleniumKarapet Sarkisyan
 
Selenium test automation
Selenium test automationSelenium test automation
Selenium test automationSrikanth Vuriti
 
Test automation using selenium
Test automation using seleniumTest automation using selenium
Test automation using seleniumshreyas JC
 
Selenium introduction
Selenium introductionSelenium introduction
Selenium introductionPankaj Dubey
 
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
 
Automation - web testing with selenium
Automation - web testing with seleniumAutomation - web testing with selenium
Automation - web testing with seleniumTzirla Rozental
 
Selenium Tutorial For Beginners | What Is Selenium? | Selenium Automation Tes...
Selenium Tutorial For Beginners | What Is Selenium? | Selenium Automation Tes...Selenium Tutorial For Beginners | What Is Selenium? | Selenium Automation Tes...
Selenium Tutorial For Beginners | What Is Selenium? | Selenium Automation Tes...Edureka!
 
Web application testing with Selenium
Web application testing with SeleniumWeb application testing with Selenium
Web application testing with SeleniumKerry Buckley
 
Selenium
SeleniumSelenium
Seleniumeduquer
 

What's hot (20)

Selenium Maven With Eclipse | Edureka
Selenium Maven With Eclipse | EdurekaSelenium Maven With Eclipse | Edureka
Selenium Maven With Eclipse | Edureka
 
Selenium- A Software Testing Tool
Selenium- A Software Testing ToolSelenium- A Software Testing Tool
Selenium- A Software Testing Tool
 
Test Automation and Selenium
Test Automation and SeleniumTest Automation and Selenium
Test Automation and Selenium
 
Automation Testing by Selenium Web Driver
Automation Testing by Selenium Web DriverAutomation Testing by Selenium Web Driver
Automation Testing by Selenium Web Driver
 
Selenium test automation
Selenium test automationSelenium test automation
Selenium test automation
 
Test automation using selenium
Test automation using seleniumTest automation using selenium
Test automation using selenium
 
Selenium introduction
Selenium introductionSelenium introduction
Selenium introduction
 
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 with java
Selenium with javaSelenium with java
Selenium with java
 
Selenium ppt
Selenium pptSelenium ppt
Selenium ppt
 
Automation - web testing with selenium
Automation - web testing with seleniumAutomation - web testing with selenium
Automation - web testing with selenium
 
Selenium Tutorial For Beginners | What Is Selenium? | Selenium Automation Tes...
Selenium Tutorial For Beginners | What Is Selenium? | Selenium Automation Tes...Selenium Tutorial For Beginners | What Is Selenium? | Selenium Automation Tes...
Selenium Tutorial For Beginners | What Is Selenium? | Selenium Automation Tes...
 
Selenium Automation Framework
Selenium Automation  FrameworkSelenium Automation  Framework
Selenium Automation Framework
 
Selenium
SeleniumSelenium
Selenium
 
Web application testing with Selenium
Web application testing with SeleniumWeb application testing with Selenium
Web application testing with Selenium
 
Selenium
SeleniumSelenium
Selenium
 
Selenium ppt
Selenium pptSelenium ppt
Selenium ppt
 
Selenium introduction
Selenium introductionSelenium introduction
Selenium introduction
 
Selenium Demo
Selenium DemoSelenium Demo
Selenium Demo
 
Selenium IDE LOCATORS
Selenium IDE LOCATORSSelenium IDE LOCATORS
Selenium IDE LOCATORS
 

Similar to Selenium WebDriver with Java

Selenium WebDriver
Selenium WebDriverSelenium WebDriver
Selenium WebDriverRajathi-QA
 
Efficient Rails Test-Driven Development - Week 6
Efficient Rails Test-Driven Development - Week 6Efficient Rails Test-Driven Development - Week 6
Efficient Rails Test-Driven Development - Week 6Marakana Inc.
 
2010 07-18.wa.rails tdd-6
2010 07-18.wa.rails tdd-62010 07-18.wa.rails tdd-6
2010 07-18.wa.rails tdd-6Marakana Inc.
 
Selenium training
Selenium trainingSelenium training
Selenium trainingShivaraj R
 
What is the taste of the Selenide
What is the taste of the SelenideWhat is the taste of the Selenide
What is the taste of the SelenideRoman Marinsky
 
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)Doris Chen
 
Improving Your Selenium WebDriver Tests - Belgium testing days_2016
Improving Your Selenium WebDriver Tests - Belgium testing days_2016Improving Your Selenium WebDriver Tests - Belgium testing days_2016
Improving Your Selenium WebDriver Tests - Belgium testing days_2016Roy de Kleijn
 
Comprehensive Browser Automation Solution using Groovy, WebDriver & Obect Model
Comprehensive Browser Automation Solution using Groovy, WebDriver & Obect ModelComprehensive Browser Automation Solution using Groovy, WebDriver & Obect Model
Comprehensive Browser Automation Solution using Groovy, WebDriver & Obect ModelvodQA
 
Selenium Tips & Tricks, presented at the Tel Aviv Selenium Meetup
Selenium Tips & Tricks, presented at the Tel Aviv Selenium MeetupSelenium Tips & Tricks, presented at the Tel Aviv Selenium Meetup
Selenium Tips & Tricks, presented at the Tel Aviv Selenium MeetupDave Haeffner
 
Top100summit 谷歌-scott-improve your automated web application testing
Top100summit  谷歌-scott-improve your automated web application testingTop100summit  谷歌-scott-improve your automated web application testing
Top100summit 谷歌-scott-improve your automated web application testingdrewz lin
 
Escape from the automation hell
Escape from the automation hellEscape from the automation hell
Escape from the automation hellNikita Simonovets
 
Complete_QA_Automation_Guide__1696637878.pdf
Complete_QA_Automation_Guide__1696637878.pdfComplete_QA_Automation_Guide__1696637878.pdf
Complete_QA_Automation_Guide__1696637878.pdframya9288
 
Android testing-with-selenium-webdriver Online Training
Android testing-with-selenium-webdriver Online TrainingAndroid testing-with-selenium-webdriver Online Training
Android testing-with-selenium-webdriver Online TrainingNagendra Kumar
 
Hdv309 - Real World Sandboxed Solutions
Hdv309 - Real World Sandboxed SolutionsHdv309 - Real World Sandboxed Solutions
Hdv309 - Real World Sandboxed Solutionswoutervugt
 

Similar to Selenium WebDriver with Java (20)

Selenium WebDriver
Selenium WebDriverSelenium WebDriver
Selenium WebDriver
 
Web driver training
Web driver trainingWeb driver training
Web driver training
 
Efficient Rails Test-Driven Development - Week 6
Efficient Rails Test-Driven Development - Week 6Efficient Rails Test-Driven Development - Week 6
Efficient Rails Test-Driven Development - Week 6
 
2010 07-18.wa.rails tdd-6
2010 07-18.wa.rails tdd-62010 07-18.wa.rails tdd-6
2010 07-18.wa.rails tdd-6
 
Introduction to selenium web driver
Introduction to selenium web driverIntroduction to selenium web driver
Introduction to selenium web driver
 
Selenium training
Selenium trainingSelenium training
Selenium training
 
What is the taste of the Selenide
What is the taste of the SelenideWhat is the taste of the Selenide
What is the taste of the Selenide
 
Selenium.pptx
Selenium.pptxSelenium.pptx
Selenium.pptx
 
J query module1
J query module1J query module1
J query module1
 
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
jQuery Makes Writing JavaScript Fun Again (for HTML5 User Group)
 
Improving Your Selenium WebDriver Tests - Belgium testing days_2016
Improving Your Selenium WebDriver Tests - Belgium testing days_2016Improving Your Selenium WebDriver Tests - Belgium testing days_2016
Improving Your Selenium WebDriver Tests - Belgium testing days_2016
 
Comprehensive Browser Automation Solution using Groovy, WebDriver & Obect Model
Comprehensive Browser Automation Solution using Groovy, WebDriver & Obect ModelComprehensive Browser Automation Solution using Groovy, WebDriver & Obect Model
Comprehensive Browser Automation Solution using Groovy, WebDriver & Obect Model
 
Selenium testing - Handle Elements in WebDriver
Selenium testing - Handle Elements in WebDriver Selenium testing - Handle Elements in WebDriver
Selenium testing - Handle Elements in WebDriver
 
Selenium Tips & Tricks, presented at the Tel Aviv Selenium Meetup
Selenium Tips & Tricks, presented at the Tel Aviv Selenium MeetupSelenium Tips & Tricks, presented at the Tel Aviv Selenium Meetup
Selenium Tips & Tricks, presented at the Tel Aviv Selenium Meetup
 
Top100summit 谷歌-scott-improve your automated web application testing
Top100summit  谷歌-scott-improve your automated web application testingTop100summit  谷歌-scott-improve your automated web application testing
Top100summit 谷歌-scott-improve your automated web application testing
 
Escape from the automation hell
Escape from the automation hellEscape from the automation hell
Escape from the automation hell
 
Complete_QA_Automation_Guide__1696637878.pdf
Complete_QA_Automation_Guide__1696637878.pdfComplete_QA_Automation_Guide__1696637878.pdf
Complete_QA_Automation_Guide__1696637878.pdf
 
Selenium web driver
Selenium web driverSelenium web driver
Selenium web driver
 
Android testing-with-selenium-webdriver Online Training
Android testing-with-selenium-webdriver Online TrainingAndroid testing-with-selenium-webdriver Online Training
Android testing-with-selenium-webdriver Online Training
 
Hdv309 - Real World Sandboxed Solutions
Hdv309 - Real World Sandboxed SolutionsHdv309 - Real World Sandboxed Solutions
Hdv309 - Real World Sandboxed Solutions
 

More from Fayis-QA

HP LoadRunner
HP LoadRunnerHP LoadRunner
HP LoadRunnerFayis-QA
 
VBScript in Software Testing
VBScript in Software TestingVBScript in Software Testing
VBScript in Software TestingFayis-QA
 
Core Java Basics
Core Java BasicsCore Java Basics
Core Java BasicsFayis-QA
 
Introduction to Automation Testing
Introduction to Automation TestingIntroduction to Automation Testing
Introduction to Automation TestingFayis-QA
 
Defect Life Cycle
Defect Life CycleDefect Life Cycle
Defect Life CycleFayis-QA
 
Testing Concepts and Manual Testing
Testing Concepts and Manual TestingTesting Concepts and Manual Testing
Testing Concepts and Manual TestingFayis-QA
 
Quality Standard
Quality StandardQuality Standard
Quality StandardFayis-QA
 
Agile in QA
Agile in QAAgile in QA
Agile in QAFayis-QA
 
Introduction to Software Testing Part- 2
Introduction to Software Testing Part- 2Introduction to Software Testing Part- 2
Introduction to Software Testing Part- 2Fayis-QA
 
Test Case Design and Technique
Test Case Design and TechniqueTest Case Design and Technique
Test Case Design and TechniqueFayis-QA
 
Test Strategies and Planning
Test Strategies and PlanningTest Strategies and Planning
Test Strategies and PlanningFayis-QA
 
Test Management
Test ManagementTest Management
Test ManagementFayis-QA
 
Types of Testing
Types of TestingTypes of Testing
Types of TestingFayis-QA
 

More from Fayis-QA (16)

HP LoadRunner
HP LoadRunnerHP LoadRunner
HP LoadRunner
 
VBScript in Software Testing
VBScript in Software TestingVBScript in Software Testing
VBScript in Software Testing
 
Core Java Basics
Core Java BasicsCore Java Basics
Core Java Basics
 
Introduction to Automation Testing
Introduction to Automation TestingIntroduction to Automation Testing
Introduction to Automation Testing
 
HP ALM QC
HP ALM QCHP ALM QC
HP ALM QC
 
Defect Life Cycle
Defect Life CycleDefect Life Cycle
Defect Life Cycle
 
Testing Concepts and Manual Testing
Testing Concepts and Manual TestingTesting Concepts and Manual Testing
Testing Concepts and Manual Testing
 
Quality Standard
Quality StandardQuality Standard
Quality Standard
 
Agile in QA
Agile in QAAgile in QA
Agile in QA
 
SDLC
SDLCSDLC
SDLC
 
Introduction to Software Testing Part- 2
Introduction to Software Testing Part- 2Introduction to Software Testing Part- 2
Introduction to Software Testing Part- 2
 
Test Case Design and Technique
Test Case Design and TechniqueTest Case Design and Technique
Test Case Design and Technique
 
Test Strategies and Planning
Test Strategies and PlanningTest Strategies and Planning
Test Strategies and Planning
 
Agile
Agile Agile
Agile
 
Test Management
Test ManagementTest Management
Test Management
 
Types of Testing
Types of TestingTypes of Testing
Types of Testing
 

Recently uploaded

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 StreamsRoshan Dwivedi
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
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 2024The Digital Insurer
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
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...Martijn de Jong
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
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...Neo4j
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 

Recently uploaded (20)

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
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
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
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
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...
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL 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...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 

Selenium WebDriver with Java

  • 1. Quality Assurance / Software Testing Training
  • 2. Page 2Classification: Restricted Agenda • Overview of Selenium WebDriver • Get Selenium WebDriver Java • Selenium – JAVA Configuration • WebDriver in Different Browsers • Open Application • Browser Settings • Locating Elements • Object Identification Methods • Locator ID, Name • Locators –LinkText, partialLinkText, CSS, CSS • Accessing different objects in application • Switch Window • Wait in WebDriver • Verifications • WebTable
  • 3. Page 3Classification: Restricted • Selenium WebDriver - is latest version of Selenium (Selenium 2/3) • WebDriver is a compact Object Oriented API when compared to Selenium1.0 • It drives the browser much more effectively • WebDriver will support following programming languages • Java, C#, Ruby, Python, JavaScript (Node.js) • Selenium WebDriver will support following browsers • Google Chrome, Internet Explorer, Firefox, Safari, Opera, Edge (Win 10) Overview of Selenium WebDriver
  • 4. Page 4Classification: Restricted • Selenium WebDriver is available from Selenium official website (http://www.seleniumhq.org) • It is an open source and free software • Source code is available in https://github.com/SeleniumHQ/selenium Get Selenium WebDriver Java
  • 5. Page 5Classification: Restricted • Install Java JDK (1.8 is recommended) • Install Java IDE (Eclipse Kepler) • Download Selenium Java jar files (http://www.seleniumhq.org/download/) • Install and configure browsers in the system • Download required browser driver Selenium – JAVA configuration
  • 6. Page 6Classification: Restricted • Open Eclipse with Workspace • Create a new Java project (As mentioned in the Core Java session) • Right click on the project and go to Build Path -> Configure Build Path Selenium – JAVA Project creation
  • 7. Page 7Classification: Restricted Selenium – JAVA Project creation 7 • Go to Libraries Tab and click on Add External Jars… to select selenium Jar files • Select all jars which are download then click on Open and click on OK
  • 8. Page 8Classification: Restricted WebDriver in Different Browsers 8 • Google Chrome • Mozilla Firefox • MS Internet Explorer • Safari WebDriver driver; System.setProperty("webdriver.chrome.driver", “<<Path of chromedriver.exe>>"); driver = new ChromeDriver(); System.setProperty("webdriver.gecko.driver", “<<path of geckodriver.exe>>"); driver = new FirefoxDriver(); System.setProperty(“webdriver.ie.driver ",“<<Path of IEDriverServer.exe>>"); driver = new InternetExplorerDriver(); driver = new SafariDriver();
  • 9. Page 9Classification: Restricted • MS Edge(Windows 10) System.setProperty("webdriver.edge.driver", “<<path of MicrosoftWebDriver.exe“>>); driver = new EdgeDriver(); WebDriver in Different Browsers
  • 10. Page 10Classification: Restricted • Pre-requisites to open a URL • Browser need to be installed • Browser driver need to upgrade based on browser version • Browser zoom level should be 100% • Syntax to open url is, driver.get(“http://google.com/”); Open Application
  • 11. Page 11Classification: Restricted • For Internet Explorer, • On IE 7 or higher on Windows, must set the Protected Mode settings for each zone to be the same value. • The value can be on or off, as long as it is the same for every zone. Browser Settings
  • 12. Page 12Classification: Restricted • To set the Protected Mode settings, choose "Internet Options..." from the Tools menu, and click on the Security tab. • For each zone, there will be a check box at the bottom of the tab labeled "Enable Protected Mode" Browser Settings
  • 13. Page 13Classification: Restricted • Locating elements in WebDriver is done by using the findElement(By.locator()) method Variati on Description Sample By.id locates elements by the value of their "id" attribute findElement(By.id("someId ")) By.nam e locates elements by the value of the "name" attribute findElement(By.name("so meName")) By.linkT ext finds a link element by the exact text it displays findElement(By.linkText("R EGISTRATION")) By.parti alLinkTe xt locates elements that contain the given link text findElement(By.partialLink Text("REG")) By.cssS elector finds elements based on the driver's underlying CSS Selector engine findElement(By.cssSelector ("input#email")) Locating Elements
  • 14. Page 14Classification: Restricted Variati on Description Sample By.class Name finds elements based on the value of the "class" attribute findElement(By.className ("someClassName")) By.tagN ame locates elements by their tag name findElement(By.tagName(" div")) By.xpat h locates elements via XPath findElement(By.xpath(“//in put[@id=‘username’]")) Locating Elements
  • 15. Page 15Classification: Restricted IE Developer tool: • Press F12 to open developer tool • Click on the arrow key to select the object to get the property • Click on Attribute to get different object attributes Object Identification Methods
  • 16. Page 16Classification: Restricted Chrome: Inspect element • Right click on the object you want identify and select Inspect element option • Find different properties available with the object or right click on highlighted code and select copy CSS path or Copy Xpath Object Identification Methods
  • 17. Page 17Classification: Restricted Firefox: Inspect element • Right click on the object you want identify and select Inspect element (Q) option • Find different properties available with the object Firebug (Firefox add-on) • Firebug has different methods to select the object properties • Find for the code • Select properties for DOM • Copy Xpath • Copy CSS file Object Identification Methods
  • 18. Page 18Classification: Restricted Selenium IDE • Enter the object property Target column and click on Find button to check the object • Click on Select and highlight the object to get the object properties Object Identification Methods
  • 19. Page 19Classification: Restricted The Id strategy looks for an element in the page having an id attribute corresponding to the specified pattern. <label id="my_id" /> will be matched by a locator like id=my_id or just my_id driver.findElement(By.id("my_id")); Locator ID
  • 20. Page 20Classification: Restricted Is the Id strategy, but on the name attribute <html> <body> <div id="pancakes"> <button type="button" name="pancake“ value="Blueberry">Blueberry</button> </div> </body> </html> driver.findElement(By.name("pancake")); Locator Name
  • 21. Page 21Classification: Restricted select links only and selects the anchor element containing the specified text: link=The text of the link <a href="http://www.phptravels.net/offers.html" target="_self"> Offers</a> driver.findElement(By.linkText("Offers")); Locators -LinkText
  • 22. Page 22Classification: Restricted  select links only and selects the anchor element containing the specified text: link=The text of the link and take the part of the link  <a href="mercuryunderconst.php?osCsid=af0ce02d7eb466b9a4ec43f 2d5273db9">Car Rentals</a> driver.findElement(By.partialLinkText("Ren")); Locators -partialLinkText
  • 23. Page 23Classification: Restricted  CSS Selectors are string patterns used to identify an element based on a combination of HTML tag, id, class, and attributes. Locating by CSS Selector is more complicated than the previous methods, but it is the most common locating strategy of advanced Selenium users because it can access even those elements that have no ID or name. driver.findElement(By.cssSelector("input #usernme")); Locators -CSS
  • 24. Page 24Classification: Restricted  XPath is the standard navigation tool for XML; and an HTML document is also an XML document (xHTML). XPath is used everywhere where there is XML.  It can access almost any element, even those without class, name, or id attributes.  It is the most complicated method of identifying elements because of too many different rules and considerations. driver.findElement(By.xpath("//input[@id = 'usernme']")); Locators -Xpath
  • 25. Page 25Classification: Restricted  Dropdown, Multi select  Declare the drop-down element  Select elmDrp=new Select (WebElement)  elmDrp.selectByVisibleText(”text ”)  deselectByVisibleText()  selectByIndex()  deselectByIndex()  isMultiple()  deselectAll()  Text Fields  .sendKeys(“value”)  .clear()  Radio button, Link  .click()  Checkbox  .click()  .isSelected() Accessing Different Objects in Application
  • 26. Page 26Classification: Restricted  Switching Between Frames  driver.switchTo().frame(“FrameName”)  Switching Between Pop-up Windows  driver.switchTo().alert()  Get pop-up message  driver.switchTo().alert().getText()  Click on OK on pop-up  driver.switchTo().alert().accept() Switch Window
  • 27. Page 27Classification: Restricted  Implicit wait  Used to set the default waiting time throughout the program  driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);  Explicit wait  used to set the waiting time for a particular instance only  WebDriverWait wait = new WebDriverWait(driver,10);  wait.until(ExpectedConditions.visibilityOfElementLocated(By.n ame("userName"))); Wait in WebDriver
  • 28. Page 28Classification: Restricted  Check object exist  driver.findElements(obj).size()  driver.findElement(obj).isDisplayed()  isEnabled()  isDisplayed()  isSelected()  elementToBeClickable()  frameToBeAvailableAndSwitchToIt() Verifications
  • 29. Page 29Classification: Restricted  To get items from a table we can create object by table xpath  To get value from different row and column create dynamic object run time  String xpath = "//table[@width="270"]/tbody/tr[" + row + "]/td[" + col + "]";  driver.findElement(By.xpath(xpath)).getText();  Can create table xpath with some unique property WebTable