SlideShare a Scribd company logo
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 ?

More Related Content

KEY
JavaScript Testing VIA Selenium
PDF
Automated Web Testing using JavaScript
PPTX
Selenium for Jobseekers
PDF
Introduction to Protractor
PDF
Upgrading to Selenium WebDriver version 3
PPTX
Web driver training
PDF
Selenium webdriver
PPTX
Selenium Automation at Incapsula
JavaScript Testing VIA Selenium
Automated Web Testing using JavaScript
Selenium for Jobseekers
Introduction to Protractor
Upgrading to Selenium WebDriver version 3
Web driver training
Selenium webdriver
Selenium Automation at Incapsula

What's hot (20)

PPTX
Protractor for angularJS
PPTX
Automated testing with Drupal
PPTX
Protractor overview
PDF
Join the darkside: Selenium testing with Nightwatch.js
KEY
Jellyfish, JSCONF 2011
PPTX
How to Configure Selenium WebDriver (java)
PPT
Automation with Selenium Presented by Quontra Solutions
PDF
Carmen Popoviciu - Protractor styleguide | Codemotion Milan 2015
PDF
Session on Selenium Powertools by Unmesh Gundecha
PDF
Front-End Testing: Demystified
PDF
How To Use Selenium Successfully (Java Edition)
PDF
Nightwatch at Tilt
PDF
Selenium testing
DOCX
Protractor end-to-end testing framework for angular js
PPTX
Better End-to-End Testing with Page Objects Model using Protractor
PPTX
Automated Testing using JavaScript
PDF
Testing Code.org's Interactive CS Curriculum
PPTX
Protractor
PPTX
Moving From a Selenium Grid to the Cloud - A Real Life Story
PPTX
Automation using Javascript
Protractor for angularJS
Automated testing with Drupal
Protractor overview
Join the darkside: Selenium testing with Nightwatch.js
Jellyfish, JSCONF 2011
How to Configure Selenium WebDriver (java)
Automation with Selenium Presented by Quontra Solutions
Carmen Popoviciu - Protractor styleguide | Codemotion Milan 2015
Session on Selenium Powertools by Unmesh Gundecha
Front-End Testing: Demystified
How To Use Selenium Successfully (Java Edition)
Nightwatch at Tilt
Selenium testing
Protractor end-to-end testing framework for angular js
Better End-to-End Testing with Page Objects Model using Protractor
Automated Testing using JavaScript
Testing Code.org's Interactive CS Curriculum
Protractor
Moving From a Selenium Grid to the Cloud - A Real Life Story
Automation using Javascript
Ad

Viewers also liked (20)

DOC
A native american_welcome
PPSX
Build my dream 4 opdracht 01
PPT
vAcademia 2015
PDF
Виртуальная образовательная среда vAcademia : модная игрушка или прорыв в e...
PPSX
Bmd opdracht 5
PPT
DOC
Thanksgiving my activity
PPT
E learning-2004
PPSX
Bmd opdracht 2
PDF
Enforcing coding standards in a JS project
PPSX
Bmd 6 o1 show
PPT
Vacademia 31 10 2013 moscow
PPT
PPSX
BMD opdracht 1
PPT
Halloween info
PPSX
Bmd opdracht 6.1
PPSX
Bmd opdracht 3 huis2
PPTX
Bmd opdracht 2
PPTX
How to make courseware for schools interesting
A native american_welcome
Build my dream 4 opdracht 01
vAcademia 2015
Виртуальная образовательная среда vAcademia : модная игрушка или прорыв в e...
Bmd opdracht 5
Thanksgiving my activity
E learning-2004
Bmd opdracht 2
Enforcing coding standards in a JS project
Bmd 6 o1 show
Vacademia 31 10 2013 moscow
BMD opdracht 1
Halloween info
Bmd opdracht 6.1
Bmd opdracht 3 huis2
Bmd opdracht 2
How to make courseware for schools interesting
Ad

Similar to Getting started with Selenium 2 (20)

PDF
Automated UI testing.Selenium.DrupalCamp Kyiv 2011
PPTX
Introduction to the Selenium_Session1.pptx
PPTX
Basics of selenium containing features of selenium
PDF
selenium-webdriver-interview-questions.pdf
PPTX
Test Automation Using Selenium
PPTX
Selenium Tutorial For Beginners | Selenium Automation Testing Tutorial | Sele...
DOCX
Selenium WebDriver FAQ's
PPTX
Introduction to Selenium Web Driver
DOCX
Best Selenium Online Training
PPTX
Introduction to selenium web driver
PPTX
Selenium Basics and Overview topics.pptx
PPTX
Selenium Basics and Overview1233444.pptx
PPTX
Selenium WebDriver Tutorial | Selenium WebDriver Tutorial For Beginner | Sele...
PPT
Selenium
ODP
Automated UI testing. Selenium. DrupalCamp Kyiv 2011
PPTX
Selenium Tutorial For Beginners | What Is Selenium? | Selenium Automation Tes...
PDF
Testing world selenium_start_chapter1 (1)
PPTX
前端網頁自動測試
PPT
Understanding Selenium/RC, Webdriver Architecture and developing the page obj...
PPTX
Selenium Web Driver Tutorial for Cross Browser Testing
Automated UI testing.Selenium.DrupalCamp Kyiv 2011
Introduction to the Selenium_Session1.pptx
Basics of selenium containing features of selenium
selenium-webdriver-interview-questions.pdf
Test Automation Using Selenium
Selenium Tutorial For Beginners | Selenium Automation Testing Tutorial | Sele...
Selenium WebDriver FAQ's
Introduction to Selenium Web Driver
Best Selenium Online Training
Introduction to selenium web driver
Selenium Basics and Overview topics.pptx
Selenium Basics and Overview1233444.pptx
Selenium WebDriver Tutorial | Selenium WebDriver Tutorial For Beginner | Sele...
Selenium
Automated UI testing. Selenium. DrupalCamp Kyiv 2011
Selenium Tutorial For Beginners | What Is Selenium? | Selenium Automation Tes...
Testing world selenium_start_chapter1 (1)
前端網頁自動測試
Understanding Selenium/RC, Webdriver Architecture and developing the page obj...
Selenium Web Driver Tutorial for Cross Browser Testing

More from Sebastiano Armeli (11)

PDF
Managing a software engineering team
PDF
Enforcing coding standards
PDF
ES6: The future is now
PDF
EcmaScript 6 - The future is here
PDF
Dependency management & Package management in JavaScript
PDF
Karma - JS Test Runner
PDF
KEY
Lazy load Everything!
KEY
MVC on the server and on the client
KEY
Backbone.js in a real-life application
PDF
Web Storage
Managing a software engineering team
Enforcing coding standards
ES6: The future is now
EcmaScript 6 - The future is here
Dependency management & Package management in JavaScript
Karma - JS Test Runner
Lazy load Everything!
MVC on the server and on the client
Backbone.js in a real-life application
Web Storage

Recently uploaded (20)

PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Empathic Computing: Creating Shared Understanding
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Electronic commerce courselecture one. Pdf
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
Unlocking AI with Model Context Protocol (MCP)
PPTX
A Presentation on Artificial Intelligence
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
Chapter 3 Spatial Domain Image Processing.pdf
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Network Security Unit 5.pdf for BCA BBA.
Spectral efficient network and resource selection model in 5G networks
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Empathic Computing: Creating Shared Understanding
Per capita expenditure prediction using model stacking based on satellite ima...
Encapsulation_ Review paper, used for researhc scholars
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Review of recent advances in non-invasive hemoglobin estimation
NewMind AI Weekly Chronicles - August'25 Week I
Electronic commerce courselecture one. Pdf
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Reach Out and Touch Someone: Haptics and Empathic Computing
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Unlocking AI with Model Context Protocol (MCP)
A Presentation on Artificial Intelligence
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
Chapter 3 Spatial Domain Image Processing.pdf

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

Editor's Notes