SlideShare a Scribd company logo
WebDriver Training
Trainer: Dipesh Bhatewara
www.digitalinfobytes.com
History
2
2004 2007 2009 2011
Selenium 1 WebDriver
Selenium2
WebDriver
 Is a Self Contained Library of APIs
 Uses browser capabilities over injected JavaScripts
 “Best fit” technology
 Clean & Object Oriented API
 Easy to maintain
 Faster than Selenium 1
 Tightly bound to the browser, no need of Selenium Server
 Bindings : Java, C#, Python, Ruby
 Android and iPhone support
3
Selenium Server in Selenium2
 Replicate Selenium RC functionalities
 Remote WebDriver
 Selenium Grid 2
4
WebDriver
WebDriver Interface
Firefox
Driver
Internet
Explorer
Driver
Chrome
Driver
HTML
Unit
Driver
Opera
Driver
Andriod
Driver
iPhone
Driver
5
API – Must Know
 Webdriver – Control Browser
 Webdriver driver = new FirefoxDriver();
 WebElement – works with elements on page
 WebElement username =
driver.findElement(By.id(“user”));
API – Must Know
 void get(“url”) - open the web page
 void quit() - close the browser
 List<WebElement> findElements(By by) - find elements (more than one
element)
API – Find Elements
 There are many different ways to find elements
 By.id(“objectId”)
 By.linkText(“textUsedInTheLink”)
 By.partialLinkText(“partOftextUsedInTheLink”)
 By.tagName(“HTMLNodeTag”)
 By.className(“cssClassOnObject”)
 By.cssSelector(“cssSelectorOfElement”)
 By.xpath(“//xpath/To/Element”)
 By.name(“elementName”)
API - Operations
 void click() - click on an element
 void submit() - perform a submit
 String getValue() – returns value set in the element
 void sendKeys(“keysToSend”) - input values
 void clear() - clear the input field
 String getElementName() – returns value of Name of the element
 String getAttriubute() – returns value of specified attribute of the element
 void Actions() - perform mouse, drag and drops and keyboard operations
www.time2test.co.uk !
API - windows and frames working with
Browser
 Windows
 driver.getWindowHandles()
 driver.switchTo().window.(“window_name”)
 Working with frames • driver.switchTo().frame.(“frame_name”)
Finding Dynamic Elements
 Does the ID of your element dynamically change?
<p id="bootcamp_dynamic_1234">This p tag has a dynamic id</p>
 Xpath notation to find the p tag on the page
"//p[contains(@id,'bootcamp_dynamic_')]"
Locator Strategies
 ID
 webDriver.findElement(By.id("logo"));
 Name
 webDriver.findElement(By.name("q"));
 Tag Name
 webDriver.findElement(By.tagName("H1"));
 Class name
 webDriver.findElements(By.className("sponsor_logos"));
 XPath
 webDriver.findElement(By.xpath("//section[@id=‘miniconfs’]/a[2]"));
 Link Text
 webDriver.findElements(By.linkText("About"));
 Partial Link Text
 webDriver.findElement(By.partialLinkText("visitcanberra"));
12
Sample Codes
 Clicking Button/Link/CheckBox
 Type in Textbox
driver.findElement(By.id("submitButton")).
click();
driver.findElement(By.name("fname")).sendKeys
("My First Name");
Sample Codes
 Selecting from Drop Down/Radio button
<select id="44"> <option value="1">xyz</option>
<option value="2">abc</option>
<option value="3">pqr</option>
</select>
WebElement e = driver.findElement(By.id("44"));
Select selectElement=new Select(e);
// both of the below statements will select first
option in the weblist
selectElement.selectByVisibleText("xyz");
selectElement.selectByValue("1");
Sample Codes
 Store text of targeted element
 Get page title
String dropdown =
driver.findElement(By.tagName("select")).getText();
driver.getTitle();
Sample Code for Demonstration
16
Let’s code
 Try the commands seen on your application under test using Selenium, Java,
TestNG and Eclipse
 Eclipse-Java-Selenium environment setup Reference -
http://qastuff.blogspot.in/2012/03/setting-up-selenium-web-driver-
eclipse.html
17
Page Interactions
 webElement.click()
 webElement.sendKeys(...)
 webElement.submit()
 Actions class -> Mouse Events / Drag and Drop
18
Advanced: Waits in Webdriver
 Waiting is having the automated task execution elapse a certain amount of
time before continuing with the next step.
 Worst way of waiting is Thread.sleep();
Advanced Example: Implicit Wait
 An implicit wait is to tell WebDriver to poll the DOM for a certain amount of
time when trying to find an element or elements if they are not immediately
available. The default setting is 0. Once set, the implicit wait is set for the
life of the WebDriver object instance.
WebDriver webdriver = new FirefoxDriver();
webdriver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
webdriver.get("http://somedomain/url_that_delays_loading");
WebElement myDynamicElement =
webdriver.findElement(By.id("myDynamicElement"));
Advanced Example: Explicit Wait
An explicit waits is code you define to wait for a certain condition to occur
before proceeding further in the code.
WebElement myDynamicElement = (new WebDriverWait(driver,
10)).until(ExpectedConditions.presenceOfElementLocated(By.id("myDynamicE
lement")));
WebElement element =
wait.until(ExpectedConditions.elementToBeClickable(By.id("someid")));
Some conditions for Explicit wait
 ExpectedConditions.elementToBeClickable(locator);
 ExpectedConditions.invisibilityOfElementLocated(locator);
 ExpectedConditions.alertIsPresent();
 ExpectedConditions.presenceOfElementLocated(locator);
 ExpectedConditions.textToBePresentInElement(locator, text);
 ExpectedConditions.visibilityOf(element);
Advanced Examples
 Capture Screenshot
File screenshot =
((TakesScreenshot)driver).getScreenshotAs(OutputType.
FILE);
FileUtils.copyFile(screenshot, new
File("D:screenshot.jpg"));
Best Practice
 To use implicit wait and explicit wait together
 Define implicit wait for driver after initialization
 This will define default implicit wait time frame for all findElements
 At the special places requiring more time, use explicit wait
Additional useful commands
 Polling the DOM for N seconds
 webDriver.manage().timeouts().implicitlyWait(30,
TimeUnit.SECONDS);
 Testing CSS properties
 webElement.getCssValue(“height”);
 Javascript execution
 JavascriptExecutor js = (JavascriptExecutor) webDriver;
 Long value = (Long) js.executeScript("return
window.scrollY");
 Navigation
 webDriver.navigate().back();
 webDriver.navigate().forward();
 webDriver.navigate().to(“url”); 25
Assignment
 Fill the form of registration on a test website of your choice.
 Run it on different browsers.
 Try to use waits.
26
Pop-up/Alert handling
 Pop up window
 driver.switchTo().window(windowHandle);
 Alerts
 alert = driver.switchTo().alert();
 alert.Accept();
 alert.Dismiss();
 Sample code Reference - http://qastuff.blogspot.in/2012/05/switch-to-
window-smart-way.html
27
Backward Compatibility with Selenium 1
Selenium selenium = new
WebDriverBackedSelenium(webDriver,
“http://osdc.com.au”);
selenium.open("http://osdc.com.au");
selenium.click("id=follow_twitter");
selenium.waitForPageToLoad("10000");
WebDriver webDriver = ((WebDriverBackedSelenium)
selenium).getUnderlyingWebDriver(); 28
Dipesh Bhatewara
Test Automation and Agile enthusiast.
LinkedIn -https://in.linkedin.com/pub/dipesh-bhatewara/2/498/612/en
Blog - http://qastuff.blogspot.in/, www.digitalinfobytes.com
Email - dipesh.bhatewara@outlook.com

More Related Content

What's hot

Selenium testing - Handle Elements in WebDriver
Selenium testing - Handle Elements in WebDriver Selenium testing - Handle Elements in WebDriver
Selenium testing - Handle Elements in WebDriver
Vibrant Technologies & Computers
 
Getting started with Selenium 2
Getting started with Selenium 2Getting started with Selenium 2
Getting started with Selenium 2
Sebastiano Armeli
 
Selenide
SelenideSelenide
Dfc 2018 NativeScript
Dfc 2018 NativeScriptDfc 2018 NativeScript
Dfc 2018 NativeScript
Baskar rao Dsn
 
Selenium
SeleniumSelenium
Selenium Introduction by Sandeep Sharda
Selenium Introduction by Sandeep ShardaSelenium Introduction by Sandeep Sharda
Selenium Introduction by Sandeep ShardaEr. Sndp Srda
 
Олександр Хотемський “ProtractorJS як інструмент браузерної автоматизації для...
Олександр Хотемський “ProtractorJS як інструмент браузерної автоматизації для...Олександр Хотемський “ProtractorJS як інструмент браузерної автоматизації для...
Олександр Хотемський “ProtractorJS як інструмент браузерної автоматизації для...
Dakiry
 
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
Roman Marinsky
 
jQuery Proven Performance Tips & Tricks
jQuery Proven Performance Tips & TricksjQuery Proven Performance Tips & Tricks
jQuery Proven Performance Tips & Tricks
Addy Osmani
 
What you can do In WatiR
What you can do In WatiRWhat you can do In WatiR
What you can do In WatiR
Wesley Chen
 
Protractor framework – how to make stable e2e tests for Angular applications
Protractor framework – how to make stable e2e tests for Angular applicationsProtractor framework – how to make stable e2e tests for Angular applications
Protractor framework – how to make stable e2e tests for Angular applications
Ludmila Nesvitiy
 
Javascript Test Automation Workshop (21.08.2014)
Javascript Test Automation Workshop (21.08.2014)Javascript Test Automation Workshop (21.08.2014)
Javascript Test Automation Workshop (21.08.2014)
Deutsche Post
 
watir-webdriver
watir-webdriverwatir-webdriver
watir-webdriver
jariba
 
Tellurium At Rich Web Experience2009
Tellurium At Rich Web Experience2009Tellurium At Rich Web Experience2009
Tellurium At Rich Web Experience2009
John.Jian.Fang
 
Introduction to Selenium Web Driver
Introduction to Selenium Web DriverIntroduction to Selenium Web Driver
Introduction to Selenium Web Driver
Return on Intelligence
 
Scraping recalcitrant web sites with Python & Selenium
Scraping recalcitrant web sites with Python & SeleniumScraping recalcitrant web sites with Python & Selenium
Scraping recalcitrant web sites with Python & SeleniumRoger Barnes
 
Development of automated tests for ext js based web sites
Development of automated tests for ext js based web sitesDevelopment of automated tests for ext js based web sites
Development of automated tests for ext js based web sitesISsoft
 
Tellurium.A.New.Approach.For.Web.Testing
Tellurium.A.New.Approach.For.Web.TestingTellurium.A.New.Approach.For.Web.Testing
Tellurium.A.New.Approach.For.Web.Testing
John.Jian.Fang
 
An Introduction to AngularJS End to End Testing using Protractor
An Introduction to AngularJS End to End Testing using ProtractorAn Introduction to AngularJS End to End Testing using Protractor
An Introduction to AngularJS End to End Testing using Protractor
Cubet Techno Labs
 

What's hot (20)

Selenium testing - Handle Elements in WebDriver
Selenium testing - Handle Elements in WebDriver Selenium testing - Handle Elements in WebDriver
Selenium testing - Handle Elements in WebDriver
 
Getting started with Selenium 2
Getting started with Selenium 2Getting started with Selenium 2
Getting started with Selenium 2
 
Selenide
SelenideSelenide
Selenide
 
Dfc 2018 NativeScript
Dfc 2018 NativeScriptDfc 2018 NativeScript
Dfc 2018 NativeScript
 
Selenium
SeleniumSelenium
Selenium
 
Selenium Introduction by Sandeep Sharda
Selenium Introduction by Sandeep ShardaSelenium Introduction by Sandeep Sharda
Selenium Introduction by Sandeep Sharda
 
Олександр Хотемський “ProtractorJS як інструмент браузерної автоматизації для...
Олександр Хотемський “ProtractorJS як інструмент браузерної автоматизації для...Олександр Хотемський “ProtractorJS як інструмент браузерної автоматизації для...
Олександр Хотемський “ProtractorJS як інструмент браузерної автоматизації для...
 
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
 
jQuery Proven Performance Tips & Tricks
jQuery Proven Performance Tips & TricksjQuery Proven Performance Tips & Tricks
jQuery Proven Performance Tips & Tricks
 
What you can do In WatiR
What you can do In WatiRWhat you can do In WatiR
What you can do In WatiR
 
Protractor framework – how to make stable e2e tests for Angular applications
Protractor framework – how to make stable e2e tests for Angular applicationsProtractor framework – how to make stable e2e tests for Angular applications
Protractor framework – how to make stable e2e tests for Angular applications
 
Javascript Test Automation Workshop (21.08.2014)
Javascript Test Automation Workshop (21.08.2014)Javascript Test Automation Workshop (21.08.2014)
Javascript Test Automation Workshop (21.08.2014)
 
watir-webdriver
watir-webdriverwatir-webdriver
watir-webdriver
 
Tellurium At Rich Web Experience2009
Tellurium At Rich Web Experience2009Tellurium At Rich Web Experience2009
Tellurium At Rich Web Experience2009
 
Introduction to Selenium Web Driver
Introduction to Selenium Web DriverIntroduction to Selenium Web Driver
Introduction to Selenium Web Driver
 
Scraping recalcitrant web sites with Python & Selenium
Scraping recalcitrant web sites with Python & SeleniumScraping recalcitrant web sites with Python & Selenium
Scraping recalcitrant web sites with Python & Selenium
 
Selenium. going beyond the possible
Selenium. going beyond the possibleSelenium. going beyond the possible
Selenium. going beyond the possible
 
Development of automated tests for ext js based web sites
Development of automated tests for ext js based web sitesDevelopment of automated tests for ext js based web sites
Development of automated tests for ext js based web sites
 
Tellurium.A.New.Approach.For.Web.Testing
Tellurium.A.New.Approach.For.Web.TestingTellurium.A.New.Approach.For.Web.Testing
Tellurium.A.New.Approach.For.Web.Testing
 
An Introduction to AngularJS End to End Testing using Protractor
An Introduction to AngularJS End to End Testing using ProtractorAn Introduction to AngularJS End to End Testing using Protractor
An Introduction to AngularJS End to End Testing using Protractor
 

Similar to Web driver training

Introduction to selenium web driver
Introduction to selenium web driverIntroduction to selenium web driver
Introduction to selenium web driver
Return on Intelligence
 
Top 15 Selenium WebDriver Interview Questions and Answers.pdf
Top 15 Selenium WebDriver Interview Questions and Answers.pdfTop 15 Selenium WebDriver Interview Questions and Answers.pdf
Top 15 Selenium WebDriver Interview Questions and Answers.pdf
AnanthReddy38
 
Understanding Selenium/RC, Webdriver Architecture and developing the page obj...
Understanding Selenium/RC, Webdriver Architecture and developing the page obj...Understanding Selenium/RC, Webdriver Architecture and developing the page obj...
Understanding Selenium/RC, Webdriver Architecture and developing the page obj...
Atirek Gupta
 
Selenium WebDriver
Selenium WebDriverSelenium WebDriver
Selenium WebDriver
Rajathi-QA
 
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
 
Selenium web driver
Selenium web driverSelenium web driver
Selenium web driver
Sun Technlogies
 
Web UI test automation instruments
Web UI test automation instrumentsWeb UI test automation instruments
Web UI test automation instruments
Artem Nagornyi
 
Indic threads pune12-improve testing efficiency with selenium webdriver
Indic threads pune12-improve testing efficiency with selenium webdriverIndic threads pune12-improve testing efficiency with selenium webdriver
Indic threads pune12-improve testing efficiency with selenium webdriver
IndicThreads
 
Top 15 Selenium WebDriver Interview Questions and Answers.pptx
Top 15 Selenium WebDriver Interview Questions and Answers.pptxTop 15 Selenium WebDriver Interview Questions and Answers.pptx
Top 15 Selenium WebDriver Interview Questions and Answers.pptx
AnanthReddy38
 
Complete_QA_Automation_Guide__1696637878.pdf
Complete_QA_Automation_Guide__1696637878.pdfComplete_QA_Automation_Guide__1696637878.pdf
Complete_QA_Automation_Guide__1696637878.pdf
ramya9288
 
Toolbox for Selenium Tests in Java: WebDriverManager and Selenium-Jupiter
Toolbox for Selenium Tests in Java: WebDriverManager and Selenium-JupiterToolbox for Selenium Tests in Java: WebDriverManager and Selenium-Jupiter
Toolbox for Selenium Tests in Java: WebDriverManager and Selenium-Jupiter
Boni García
 
Escape from the automation hell
Escape from the automation hellEscape from the automation hell
Escape from the automation hell
Nikita Simonovets
 
Better Testing With PHP Unit
Better Testing With PHP UnitBetter Testing With PHP Unit
Better Testing With PHP Unit
sitecrafting
 
Selenium Automation in Java Using HttpWatch Plug-in
 Selenium Automation in Java Using HttpWatch Plug-in  Selenium Automation in Java Using HttpWatch Plug-in
Selenium Automation in Java Using HttpWatch Plug-in
Sandeep Tol
 
Web ui testing
Web ui testingWeb ui testing
Web ui testing
Radim Pavlicek
 
Experienced Selenium Interview questions
Experienced Selenium Interview questionsExperienced Selenium Interview questions
Experienced Selenium Interview questions
archana singh
 
Advanced SharePoint Web Part Development
Advanced SharePoint Web Part DevelopmentAdvanced SharePoint Web Part Development
Advanced SharePoint Web Part Development
Rob Windsor
 
Node.js and Selenium Webdriver, a journey from the Java side
Node.js and Selenium Webdriver, a journey from the Java sideNode.js and Selenium Webdriver, a journey from the Java side
Node.js and Selenium Webdriver, a journey from the Java side
Mek Srunyu Stittri
 
Selenium WebDriver with Java
Selenium WebDriver with JavaSelenium WebDriver with Java
Selenium WebDriver with Java
Fayis-QA
 
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
Roy de Kleijn
 

Similar to Web driver training (20)

Introduction to selenium web driver
Introduction to selenium web driverIntroduction to selenium web driver
Introduction to selenium web driver
 
Top 15 Selenium WebDriver Interview Questions and Answers.pdf
Top 15 Selenium WebDriver Interview Questions and Answers.pdfTop 15 Selenium WebDriver Interview Questions and Answers.pdf
Top 15 Selenium WebDriver Interview Questions and Answers.pdf
 
Understanding Selenium/RC, Webdriver Architecture and developing the page obj...
Understanding Selenium/RC, Webdriver Architecture and developing the page obj...Understanding Selenium/RC, Webdriver Architecture and developing the page obj...
Understanding Selenium/RC, Webdriver Architecture and developing the page obj...
 
Selenium WebDriver
Selenium WebDriverSelenium WebDriver
Selenium WebDriver
 
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
 
Selenium web driver
Selenium web driverSelenium web driver
Selenium web driver
 
Web UI test automation instruments
Web UI test automation instrumentsWeb UI test automation instruments
Web UI test automation instruments
 
Indic threads pune12-improve testing efficiency with selenium webdriver
Indic threads pune12-improve testing efficiency with selenium webdriverIndic threads pune12-improve testing efficiency with selenium webdriver
Indic threads pune12-improve testing efficiency with selenium webdriver
 
Top 15 Selenium WebDriver Interview Questions and Answers.pptx
Top 15 Selenium WebDriver Interview Questions and Answers.pptxTop 15 Selenium WebDriver Interview Questions and Answers.pptx
Top 15 Selenium WebDriver Interview Questions and Answers.pptx
 
Complete_QA_Automation_Guide__1696637878.pdf
Complete_QA_Automation_Guide__1696637878.pdfComplete_QA_Automation_Guide__1696637878.pdf
Complete_QA_Automation_Guide__1696637878.pdf
 
Toolbox for Selenium Tests in Java: WebDriverManager and Selenium-Jupiter
Toolbox for Selenium Tests in Java: WebDriverManager and Selenium-JupiterToolbox for Selenium Tests in Java: WebDriverManager and Selenium-Jupiter
Toolbox for Selenium Tests in Java: WebDriverManager and Selenium-Jupiter
 
Escape from the automation hell
Escape from the automation hellEscape from the automation hell
Escape from the automation hell
 
Better Testing With PHP Unit
Better Testing With PHP UnitBetter Testing With PHP Unit
Better Testing With PHP Unit
 
Selenium Automation in Java Using HttpWatch Plug-in
 Selenium Automation in Java Using HttpWatch Plug-in  Selenium Automation in Java Using HttpWatch Plug-in
Selenium Automation in Java Using HttpWatch Plug-in
 
Web ui testing
Web ui testingWeb ui testing
Web ui testing
 
Experienced Selenium Interview questions
Experienced Selenium Interview questionsExperienced Selenium Interview questions
Experienced Selenium Interview questions
 
Advanced SharePoint Web Part Development
Advanced SharePoint Web Part DevelopmentAdvanced SharePoint Web Part Development
Advanced SharePoint Web Part Development
 
Node.js and Selenium Webdriver, a journey from the Java side
Node.js and Selenium Webdriver, a journey from the Java sideNode.js and Selenium Webdriver, a journey from the Java side
Node.js and Selenium Webdriver, a journey from the Java side
 
Selenium WebDriver with Java
Selenium WebDriver with JavaSelenium WebDriver with Java
Selenium WebDriver with Java
 
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
 

Recently uploaded

Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
RinaMondal9
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
Rohit Gautam
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
Neo4j
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
KAMESHS29
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
Neo4j
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
danishmna97
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
Pierluigi Pugliese
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 

Recently uploaded (20)

Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 

Web driver training

  • 1. WebDriver Training Trainer: Dipesh Bhatewara www.digitalinfobytes.com
  • 2. History 2 2004 2007 2009 2011 Selenium 1 WebDriver Selenium2
  • 3. WebDriver  Is a Self Contained Library of APIs  Uses browser capabilities over injected JavaScripts  “Best fit” technology  Clean & Object Oriented API  Easy to maintain  Faster than Selenium 1  Tightly bound to the browser, no need of Selenium Server  Bindings : Java, C#, Python, Ruby  Android and iPhone support 3
  • 4. Selenium Server in Selenium2  Replicate Selenium RC functionalities  Remote WebDriver  Selenium Grid 2 4
  • 6. API – Must Know  Webdriver – Control Browser  Webdriver driver = new FirefoxDriver();  WebElement – works with elements on page  WebElement username = driver.findElement(By.id(“user”));
  • 7. API – Must Know  void get(“url”) - open the web page  void quit() - close the browser  List<WebElement> findElements(By by) - find elements (more than one element)
  • 8. API – Find Elements  There are many different ways to find elements  By.id(“objectId”)  By.linkText(“textUsedInTheLink”)  By.partialLinkText(“partOftextUsedInTheLink”)  By.tagName(“HTMLNodeTag”)  By.className(“cssClassOnObject”)  By.cssSelector(“cssSelectorOfElement”)  By.xpath(“//xpath/To/Element”)  By.name(“elementName”)
  • 9. API - Operations  void click() - click on an element  void submit() - perform a submit  String getValue() – returns value set in the element  void sendKeys(“keysToSend”) - input values  void clear() - clear the input field  String getElementName() – returns value of Name of the element  String getAttriubute() – returns value of specified attribute of the element  void Actions() - perform mouse, drag and drops and keyboard operations www.time2test.co.uk !
  • 10. API - windows and frames working with Browser  Windows  driver.getWindowHandles()  driver.switchTo().window.(“window_name”)  Working with frames • driver.switchTo().frame.(“frame_name”)
  • 11. Finding Dynamic Elements  Does the ID of your element dynamically change? <p id="bootcamp_dynamic_1234">This p tag has a dynamic id</p>  Xpath notation to find the p tag on the page "//p[contains(@id,'bootcamp_dynamic_')]"
  • 12. Locator Strategies  ID  webDriver.findElement(By.id("logo"));  Name  webDriver.findElement(By.name("q"));  Tag Name  webDriver.findElement(By.tagName("H1"));  Class name  webDriver.findElements(By.className("sponsor_logos"));  XPath  webDriver.findElement(By.xpath("//section[@id=‘miniconfs’]/a[2]"));  Link Text  webDriver.findElements(By.linkText("About"));  Partial Link Text  webDriver.findElement(By.partialLinkText("visitcanberra")); 12
  • 13. Sample Codes  Clicking Button/Link/CheckBox  Type in Textbox driver.findElement(By.id("submitButton")). click(); driver.findElement(By.name("fname")).sendKeys ("My First Name");
  • 14. Sample Codes  Selecting from Drop Down/Radio button <select id="44"> <option value="1">xyz</option> <option value="2">abc</option> <option value="3">pqr</option> </select> WebElement e = driver.findElement(By.id("44")); Select selectElement=new Select(e); // both of the below statements will select first option in the weblist selectElement.selectByVisibleText("xyz"); selectElement.selectByValue("1");
  • 15. Sample Codes  Store text of targeted element  Get page title String dropdown = driver.findElement(By.tagName("select")).getText(); driver.getTitle();
  • 16. Sample Code for Demonstration 16
  • 17. Let’s code  Try the commands seen on your application under test using Selenium, Java, TestNG and Eclipse  Eclipse-Java-Selenium environment setup Reference - http://qastuff.blogspot.in/2012/03/setting-up-selenium-web-driver- eclipse.html 17
  • 18. Page Interactions  webElement.click()  webElement.sendKeys(...)  webElement.submit()  Actions class -> Mouse Events / Drag and Drop 18
  • 19. Advanced: Waits in Webdriver  Waiting is having the automated task execution elapse a certain amount of time before continuing with the next step.  Worst way of waiting is Thread.sleep();
  • 20. Advanced Example: Implicit Wait  An implicit wait is to tell WebDriver to poll the DOM for a certain amount of time when trying to find an element or elements if they are not immediately available. The default setting is 0. Once set, the implicit wait is set for the life of the WebDriver object instance. WebDriver webdriver = new FirefoxDriver(); webdriver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); webdriver.get("http://somedomain/url_that_delays_loading"); WebElement myDynamicElement = webdriver.findElement(By.id("myDynamicElement"));
  • 21. Advanced Example: Explicit Wait An explicit waits is code you define to wait for a certain condition to occur before proceeding further in the code. WebElement myDynamicElement = (new WebDriverWait(driver, 10)).until(ExpectedConditions.presenceOfElementLocated(By.id("myDynamicE lement"))); WebElement element = wait.until(ExpectedConditions.elementToBeClickable(By.id("someid")));
  • 22. Some conditions for Explicit wait  ExpectedConditions.elementToBeClickable(locator);  ExpectedConditions.invisibilityOfElementLocated(locator);  ExpectedConditions.alertIsPresent();  ExpectedConditions.presenceOfElementLocated(locator);  ExpectedConditions.textToBePresentInElement(locator, text);  ExpectedConditions.visibilityOf(element);
  • 23. Advanced Examples  Capture Screenshot File screenshot = ((TakesScreenshot)driver).getScreenshotAs(OutputType. FILE); FileUtils.copyFile(screenshot, new File("D:screenshot.jpg"));
  • 24. Best Practice  To use implicit wait and explicit wait together  Define implicit wait for driver after initialization  This will define default implicit wait time frame for all findElements  At the special places requiring more time, use explicit wait
  • 25. Additional useful commands  Polling the DOM for N seconds  webDriver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);  Testing CSS properties  webElement.getCssValue(“height”);  Javascript execution  JavascriptExecutor js = (JavascriptExecutor) webDriver;  Long value = (Long) js.executeScript("return window.scrollY");  Navigation  webDriver.navigate().back();  webDriver.navigate().forward();  webDriver.navigate().to(“url”); 25
  • 26. Assignment  Fill the form of registration on a test website of your choice.  Run it on different browsers.  Try to use waits. 26
  • 27. Pop-up/Alert handling  Pop up window  driver.switchTo().window(windowHandle);  Alerts  alert = driver.switchTo().alert();  alert.Accept();  alert.Dismiss();  Sample code Reference - http://qastuff.blogspot.in/2012/05/switch-to- window-smart-way.html 27
  • 28. Backward Compatibility with Selenium 1 Selenium selenium = new WebDriverBackedSelenium(webDriver, “http://osdc.com.au”); selenium.open("http://osdc.com.au"); selenium.click("id=follow_twitter"); selenium.waitForPageToLoad("10000"); WebDriver webDriver = ((WebDriverBackedSelenium) selenium).getUnderlyingWebDriver(); 28
  • 29. Dipesh Bhatewara Test Automation and Agile enthusiast. LinkedIn -https://in.linkedin.com/pub/dipesh-bhatewara/2/498/612/en Blog - http://qastuff.blogspot.in/, www.digitalinfobytes.com Email - dipesh.bhatewara@outlook.com