SlideShare uma empresa Scribd logo
1 de 25
Getting started with
               Selenium 2
                      Sebastiano Armeli-Battana
                              @sebarmeli
                     https://github.com/sebarmeli



November 17 , 2011                         Open Source Developers Conference, Canberra
What is Selenium?

Open Source Web Application Testing System


Automated UI Testing


Functional type of tests


Multiple browsers, multiple languages
History


 2004        2007      2009    2011


Selenium   WebDriver
                        Selenium 2
Selenium
Selenium
Selenium Core : JavaScript Framework
Selenium
Selenium Core : JavaScript Framework
-          IDE
    Firefox Plugin
Selenium
Selenium Core : JavaScript Framework
  -            IDE
       Firefox Plugin



   -           Remote Control (RC)
	

    Server : Proxy to launch browsers
       Client libraries
Selenium
Selenium Core : JavaScript Framework
  -             IDE
        Firefox Plugin



   -            Remote Control (RC)
	

     Server : Proxy to launch browsers
        Client libraries



   -            Grid
       Distributed remote tests
WebDriver

“Best fit” language
	


Clean & Object Oriented API


HtmlUnitDriver


Java bindings
Selenium 2
  -            IDE
 -              Web Driver
	

          Bindings : Java, C#, Python, Ruby

          WebDriver API

          Simplified Architecture              Selenium Server NOT needed *



      -        Grid 2
Selenium Server


Replicate Selenium RC functionalities




Selenium Grid 2
First steps
Java / C# bindings
Selenium Server
Android APK
http://code.google.com/p/selenium/downloads/list


Chrome Driver
http://code.google.com/p/chromium/downloads/list

Ruby
gem install selenium-webdriver

Python
pip install selenium / easy_install selenium
Let’s code!
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"));

• CSS Selector
 webDriver.findElement(By.cssSelector("section#sponsor>p"));

• 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"));
Page interactions

webElement.click()


webElement.sendKeys(...)


webElement.submit()


Actions class              Mouse Events / Drag and Drop
AJAX applications
DOM Elements loaded asynchronously


a) Polling the DOM for n seconds
webDriver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);   (Java)

webDriver.manage.timeouts.implicit_wait = 30 (Ruby)

webDriver.implicit_wait(30)   (Python)




b) Wait until condition occurs
ExpectedCondition / WebDriverWait
Testing style and executing JS
Testing CSS properties
webElement.getCssValue(“height”);

webElement.getCssValue(“background-image”);




Javascript execution
JavascriptExecutor js = (JavascriptExecutor) webDriver;

Long value = (Long) js.executeScript("return window.scrollY");
TargetLocator and Navigation Interfaces

TargetLocator             Frames and Popup Dialogs
TargetLocator target = webDriver.switchTo();

WebElement element = target.frame(“name”)

Alert alert = target.alert();




Navigation               Browser buttons emulation
Navigation nav = webDriver.navigate();

nav.back(); / nav.forward(); nav.to(“url”);
Migrating from 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();
Page Object Pattern / PageFactory
Pages as Objects



Separation between DOM and services in a Page



WebDriver API not exposed



PageFactory class to easily instantiate a Page Object
Selenium Grid 2
Starting Hub
 java -jar selenium-server-standalone-2.9.0.jar -role hub


Starting WebDriver Node
 java -jar selenium-server-standalone-2.9.0.jar -role webdriver -
hub http://localhost:4444/grid/register -browser
browserName=chrome,version=15,platform=MAC -port 5556



Grid console
http://localhost:4444/grid/console



Launching Test Remotely (Java)
Mobile Testing
Selenium 2 - Java QuickStart
               Archetype
https://github.com/sebarmeli/Selenium2-Java-QuickStart-Archetype
Resources
http://www.slideshare.net/sebarmeli/getting-started-with-selenium-2


https://github.com/sebarmeli/Selenium2-Java-Demo


http://seleniumhq.org/


http://code.google.com/p/selenium/



Google Groups
Questions ?

Mais conteúdo relacionado

Mais procurados

Automation with Selenium Presented by Quontra Solutions
Automation with Selenium Presented by Quontra SolutionsAutomation with Selenium Presented by Quontra Solutions
Automation with Selenium Presented by Quontra Solutions
Quontra Solutions
 

Mais procurados (20)

Protractor for angularJS
Protractor for angularJSProtractor for angularJS
Protractor for angularJS
 
Automated testing with Drupal
Automated testing with DrupalAutomated testing with Drupal
Automated testing with Drupal
 
Protractor overview
Protractor overviewProtractor overview
Protractor overview
 
Join the darkside: Selenium testing with Nightwatch.js
Join the darkside: Selenium testing with Nightwatch.jsJoin the darkside: Selenium testing with Nightwatch.js
Join the darkside: Selenium testing with Nightwatch.js
 
Jellyfish, JSCONF 2011
Jellyfish, JSCONF 2011Jellyfish, JSCONF 2011
Jellyfish, JSCONF 2011
 
How to Configure Selenium WebDriver (java)
How to Configure Selenium WebDriver (java)How to Configure Selenium WebDriver (java)
How to Configure Selenium WebDriver (java)
 
Automation with Selenium Presented by Quontra Solutions
Automation with Selenium Presented by Quontra SolutionsAutomation with Selenium Presented by Quontra Solutions
Automation with Selenium Presented by Quontra Solutions
 
Carmen Popoviciu - Protractor styleguide | Codemotion Milan 2015
Carmen Popoviciu - Protractor styleguide | Codemotion Milan 2015Carmen Popoviciu - Protractor styleguide | Codemotion Milan 2015
Carmen Popoviciu - Protractor styleguide | Codemotion Milan 2015
 
Session on Selenium Powertools by Unmesh Gundecha
Session on Selenium Powertools by Unmesh GundechaSession on Selenium Powertools by Unmesh Gundecha
Session on Selenium Powertools by Unmesh Gundecha
 
Front-End Testing: Demystified
Front-End Testing: DemystifiedFront-End Testing: Demystified
Front-End Testing: Demystified
 
How To Use Selenium Successfully (Java Edition)
How To Use Selenium Successfully (Java Edition)How To Use Selenium Successfully (Java Edition)
How To Use Selenium Successfully (Java Edition)
 
Nightwatch at Tilt
Nightwatch at TiltNightwatch at Tilt
Nightwatch at Tilt
 
Selenium testing
Selenium testingSelenium testing
Selenium testing
 
Protractor end-to-end testing framework for angular js
Protractor   end-to-end testing framework for angular jsProtractor   end-to-end testing framework for angular js
Protractor end-to-end testing framework for angular js
 
Better End-to-End Testing with Page Objects Model using Protractor
Better End-to-End Testing with Page Objects Model using ProtractorBetter End-to-End Testing with Page Objects Model using Protractor
Better End-to-End Testing with Page Objects Model using Protractor
 
Automated Testing using JavaScript
Automated Testing using JavaScriptAutomated Testing using JavaScript
Automated Testing using JavaScript
 
Testing Code.org's Interactive CS Curriculum
Testing Code.org's Interactive CS CurriculumTesting Code.org's Interactive CS Curriculum
Testing Code.org's Interactive CS Curriculum
 
Protractor
ProtractorProtractor
Protractor
 
Moving From a Selenium Grid to the Cloud - A Real Life Story
Moving From a Selenium Grid to the Cloud - A Real Life StoryMoving From a Selenium Grid to the Cloud - A Real Life Story
Moving From a Selenium Grid to the Cloud - A Real Life Story
 
Automation using Javascript
Automation using JavascriptAutomation using Javascript
Automation using Javascript
 

Destaque

Build my dream 4 opdracht 01
Build my dream 4 opdracht 01Build my dream 4 opdracht 01
Build my dream 4 opdracht 01
DienoSaurus
 
Bmd opdracht 6.1
Bmd opdracht 6.1Bmd opdracht 6.1
Bmd opdracht 6.1
DienoSaurus
 

Destaque (20)

A native american_welcome
A native american_welcomeA native american_welcome
A native american_welcome
 
Build my dream 4 opdracht 01
Build my dream 4 opdracht 01Build my dream 4 opdracht 01
Build my dream 4 opdracht 01
 
vAcademia 2015
vAcademia 2015vAcademia 2015
vAcademia 2015
 
Виртуальная образовательная среда vAcademia : модная игрушка или прорыв в e...
Виртуальная образовательная среда  vAcademia : модная игрушка или  прорыв в e...Виртуальная образовательная среда  vAcademia : модная игрушка или  прорыв в e...
Виртуальная образовательная среда vAcademia : модная игрушка или прорыв в e...
 
Bmd opdracht 5
Bmd opdracht 5Bmd opdracht 5
Bmd opdracht 5
 
Burns night
Burns nightBurns night
Burns night
 
Sequences
SequencesSequences
Sequences
 
Thanksgiving my activity
Thanksgiving my activityThanksgiving my activity
Thanksgiving my activity
 
E learning-2004
E learning-2004E learning-2004
E learning-2004
 
Bmd opdracht 2
Bmd opdracht 2Bmd opdracht 2
Bmd opdracht 2
 
Enforcing coding standards in a JS project
Enforcing coding standards in a JS projectEnforcing coding standards in a JS project
Enforcing coding standards in a JS project
 
Bmd 6 o1 show
Bmd 6 o1 showBmd 6 o1 show
Bmd 6 o1 show
 
Vacademia 31 10 2013 moscow
Vacademia 31 10 2013 moscow Vacademia 31 10 2013 moscow
Vacademia 31 10 2013 moscow
 
Scotland pic
Scotland picScotland pic
Scotland pic
 
BMD opdracht 1
BMD opdracht 1BMD opdracht 1
BMD opdracht 1
 
Halloween info
Halloween infoHalloween info
Halloween info
 
Bmd opdracht 6.1
Bmd opdracht 6.1Bmd opdracht 6.1
Bmd opdracht 6.1
 
Bmd opdracht 3 huis2
Bmd opdracht 3 huis2Bmd opdracht 3 huis2
Bmd opdracht 3 huis2
 
Bmd opdracht 2
Bmd opdracht 2Bmd opdracht 2
Bmd opdracht 2
 
How to make courseware for schools interesting
How to make courseware for schools interestingHow to make courseware for schools interesting
How to make courseware for schools interesting
 

Semelhante a Getting started with Selenium 2

Automated UI testing.Selenium.DrupalCamp Kyiv 2011
Automated UI testing.Selenium.DrupalCamp Kyiv 2011Automated UI testing.Selenium.DrupalCamp Kyiv 2011
Automated UI testing.Selenium.DrupalCamp Kyiv 2011
camp_drupal_ua
 
Test Automation Using Selenium
Test Automation Using SeleniumTest Automation Using Selenium
Test Automation Using Selenium
Nikhil Kapoor
 
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
 
Best Selenium Online Training
Best Selenium Online TrainingBest Selenium Online Training
Best Selenium Online Training
Samatha Kamuni
 
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
 

Semelhante a Getting started with Selenium 2 (20)

Automated UI testing.Selenium.DrupalCamp Kyiv 2011
Automated UI testing.Selenium.DrupalCamp Kyiv 2011Automated UI testing.Selenium.DrupalCamp Kyiv 2011
Automated UI testing.Selenium.DrupalCamp Kyiv 2011
 
selenium-webdriver-interview-questions.pdf
selenium-webdriver-interview-questions.pdfselenium-webdriver-interview-questions.pdf
selenium-webdriver-interview-questions.pdf
 
Test Automation Using Selenium
Test Automation Using SeleniumTest Automation Using Selenium
Test Automation 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...
 
Selenium WebDriver FAQ's
Selenium WebDriver FAQ'sSelenium WebDriver FAQ's
Selenium WebDriver FAQ's
 
Introduction to Selenium Web Driver
Introduction to Selenium Web DriverIntroduction to Selenium Web Driver
Introduction to Selenium Web Driver
 
Best Selenium Online Training
Best Selenium Online TrainingBest Selenium Online Training
Best Selenium Online Training
 
Introduction to selenium web driver
Introduction to selenium web driverIntroduction to selenium web driver
Introduction to selenium web driver
 
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
SeleniumSelenium
Selenium
 
Automated UI testing. Selenium. DrupalCamp Kyiv 2011
Automated UI testing. Selenium. DrupalCamp Kyiv 2011Automated UI testing. Selenium. DrupalCamp Kyiv 2011
Automated UI testing. Selenium. DrupalCamp Kyiv 2011
 
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...
 
Testing world selenium_start_chapter1 (1)
Testing world selenium_start_chapter1 (1)Testing world selenium_start_chapter1 (1)
Testing world selenium_start_chapter1 (1)
 
前端網頁自動測試
前端網頁自動測試 前端網頁自動測試
前端網頁自動測試
 
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 Web Driver Tutorial for Cross Browser Testing
Selenium Web Driver Tutorial for Cross Browser TestingSelenium Web Driver Tutorial for Cross Browser Testing
Selenium Web Driver Tutorial for Cross Browser Testing
 
Introduction to Selenium Automation
Introduction to Selenium AutomationIntroduction to Selenium Automation
Introduction to Selenium Automation
 
Selenium
SeleniumSelenium
Selenium
 
Selenium.pptx
Selenium.pptxSelenium.pptx
Selenium.pptx
 
Selenium -Test automation for web applications
Selenium -Test automation for web applicationsSelenium -Test automation for web applications
Selenium -Test automation for web applications
 

Mais de Sebastiano Armeli (11)

Managing a software engineering team
Managing a software engineering teamManaging a software engineering team
Managing a software engineering team
 
Enforcing coding standards
Enforcing coding standardsEnforcing coding standards
Enforcing coding standards
 
ES6: The future is now
ES6: The future is nowES6: The future is now
ES6: The future is now
 
EcmaScript 6 - The future is here
EcmaScript 6 - The future is hereEcmaScript 6 - The future is here
EcmaScript 6 - The future is here
 
Dependency management & Package management in JavaScript
Dependency management & Package management in JavaScriptDependency management & Package management in JavaScript
Dependency management & Package management in JavaScript
 
Karma - JS Test Runner
Karma - JS Test RunnerKarma - JS Test Runner
Karma - JS Test Runner
 
RequireJS
RequireJSRequireJS
RequireJS
 
Lazy load Everything!
Lazy load Everything!Lazy load Everything!
Lazy load Everything!
 
MVC on the server and on the client
MVC on the server and on the clientMVC on the server and on the client
MVC on the server and on the client
 
Backbone.js in a real-life application
Backbone.js in a real-life applicationBackbone.js in a real-life application
Backbone.js in a real-life application
 
Web Storage
Web StorageWeb Storage
Web Storage
 

Último

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 

Último (20)

Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 

Getting started with Selenium 2

  • 1. Getting started with Selenium 2 Sebastiano Armeli-Battana @sebarmeli https://github.com/sebarmeli November 17 , 2011 Open Source Developers Conference, Canberra
  • 2. What is Selenium? Open Source Web Application Testing System Automated UI Testing Functional type of tests Multiple browsers, multiple languages
  • 3. History 2004 2007 2009 2011 Selenium WebDriver Selenium 2
  • 5. Selenium Selenium Core : JavaScript Framework
  • 6. Selenium Selenium Core : JavaScript Framework - IDE Firefox Plugin
  • 7. Selenium Selenium Core : JavaScript Framework - IDE Firefox Plugin - Remote Control (RC) Server : Proxy to launch browsers Client libraries
  • 8. Selenium Selenium Core : JavaScript Framework - IDE Firefox Plugin - Remote Control (RC) Server : Proxy to launch browsers Client libraries - Grid Distributed remote tests
  • 9. WebDriver “Best fit” language Clean & Object Oriented API HtmlUnitDriver Java bindings
  • 10. Selenium 2 - IDE - Web Driver Bindings : Java, C#, Python, Ruby WebDriver API Simplified Architecture Selenium Server NOT needed * - Grid 2
  • 11. Selenium Server Replicate Selenium RC functionalities Selenium Grid 2
  • 12. First steps Java / C# bindings Selenium Server Android APK http://code.google.com/p/selenium/downloads/list Chrome Driver http://code.google.com/p/chromium/downloads/list Ruby gem install selenium-webdriver Python pip install selenium / easy_install selenium
  • 14. 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")); • CSS Selector webDriver.findElement(By.cssSelector("section#sponsor>p")); • 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"));
  • 16. AJAX applications DOM Elements loaded asynchronously a) Polling the DOM for n seconds webDriver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); (Java) webDriver.manage.timeouts.implicit_wait = 30 (Ruby) webDriver.implicit_wait(30) (Python) b) Wait until condition occurs ExpectedCondition / WebDriverWait
  • 17. Testing style and executing JS Testing CSS properties webElement.getCssValue(“height”); webElement.getCssValue(“background-image”); Javascript execution JavascriptExecutor js = (JavascriptExecutor) webDriver; Long value = (Long) js.executeScript("return window.scrollY");
  • 18. TargetLocator and Navigation Interfaces TargetLocator Frames and Popup Dialogs TargetLocator target = webDriver.switchTo(); WebElement element = target.frame(“name”) Alert alert = target.alert(); Navigation Browser buttons emulation Navigation nav = webDriver.navigate(); nav.back(); / nav.forward(); nav.to(“url”);
  • 19. Migrating from 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();
  • 20. Page Object Pattern / PageFactory Pages as Objects Separation between DOM and services in a Page WebDriver API not exposed PageFactory class to easily instantiate a Page Object
  • 21. Selenium Grid 2 Starting Hub java -jar selenium-server-standalone-2.9.0.jar -role hub Starting WebDriver Node java -jar selenium-server-standalone-2.9.0.jar -role webdriver - hub http://localhost:4444/grid/register -browser browserName=chrome,version=15,platform=MAC -port 5556 Grid console http://localhost:4444/grid/console Launching Test Remotely (Java)
  • 23. Selenium 2 - Java QuickStart Archetype https://github.com/sebarmeli/Selenium2-Java-QuickStart-Archetype

Notas do Editor

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n