Getting started with               Selenium 2                      Sebastiano Armeli-Battana                              ...
What is Selenium?Open Source Web Application Testing SystemAutomated UI TestingFunctional type of testsMultiple browsers, ...
History 2004        2007      2009    2011Selenium   WebDriver                        Selenium 2
Selenium
SeleniumSelenium Core : JavaScript Framework
SeleniumSelenium Core : JavaScript Framework-          IDE    Firefox Plugin
SeleniumSelenium Core : JavaScript Framework  -            IDE       Firefox Plugin   -           Remote Control (RC)	    ...
SeleniumSelenium Core : JavaScript Framework  -             IDE        Firefox Plugin   -            Remote Control (RC)	 ...
WebDriver“Best fit” language	Clean & Object Oriented APIHtmlUnitDriverJava bindings
Selenium 2  -            IDE -              Web Driver	          Bindings : Java, C#, Python, Ruby          WebDriver API ...
Selenium ServerReplicate Selenium RC functionalitiesSelenium Grid 2
First stepsJava / C# bindingsSelenium ServerAndroid APKhttp://code.google.com/p/selenium/downloads/listChrome Driverhttp:/...
Let’s code!
Locator Strategies• Id webDriver.findElement(By.id("logo"));• Name webDriver.findElement(By.name("q"));• Tag Name webDrive...
Page interactionswebElement.click()webElement.sendKeys(...)webElement.submit()Actions class              Mouse Events / Dr...
AJAX applicationsDOM Elements loaded asynchronouslya) Polling the DOM for n secondswebDriver.manage().timeouts().implicitl...
Testing style and executing JSTesting CSS propertieswebElement.getCssValue(“height”);webElement.getCssValue(“background-im...
TargetLocator and Navigation InterfacesTargetLocator             Frames and Popup DialogsTargetLocator target = webDriver....
Migrating from Selenium 1Selenium selenium = new WebDriverBackedSelenium(webDriver,                         “http://osdc.c...
Page Object Pattern / PageFactoryPages as ObjectsSeparation between DOM and services in a PageWebDriver API not exposedPag...
Selenium Grid 2Starting Hub java -jar selenium-server-standalone-2.9.0.jar -role hubStarting WebDriver Node java -jar sele...
Mobile Testing
Selenium 2 - Java QuickStart               Archetypehttps://github.com/sebarmeli/Selenium2-Java-QuickStart-Archetype
Resourceshttp://www.slideshare.net/sebarmeli/getting-started-with-selenium-2https://github.com/sebarmeli/Selenium2-Java-De...
Questions ?
Upcoming SlideShare
Loading in...5
×

Getting started with Selenium 2

9,545

Published on

Presented at OSDC 2011, Canberra, Australia

Published in: Technology, Education
0 Comments
15 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
9,545
On Slideshare
0
From Embeds
0
Number of Embeds
5
Actions
Shares
0
Downloads
677
Comments
0
Likes
15
Embeds 0
No embeds

No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Transcript of "Getting started with Selenium 2"

    1. 1. Getting started with Selenium 2 Sebastiano Armeli-Battana @sebarmeli https://github.com/sebarmeliNovember 17 , 2011 Open Source Developers Conference, Canberra
    2. 2. What is Selenium?Open Source Web Application Testing SystemAutomated UI TestingFunctional type of testsMultiple browsers, multiple languages
    3. 3. History 2004 2007 2009 2011Selenium WebDriver Selenium 2
    4. 4. Selenium
    5. 5. SeleniumSelenium Core : JavaScript Framework
    6. 6. SeleniumSelenium Core : JavaScript Framework- IDE Firefox Plugin
    7. 7. SeleniumSelenium Core : JavaScript Framework - IDE Firefox Plugin - Remote Control (RC) Server : Proxy to launch browsers Client libraries
    8. 8. SeleniumSelenium Core : JavaScript Framework - IDE Firefox Plugin - Remote Control (RC) Server : Proxy to launch browsers Client libraries - Grid Distributed remote tests
    9. 9. WebDriver“Best fit” language Clean & Object Oriented APIHtmlUnitDriverJava bindings
    10. 10. Selenium 2 - IDE - Web Driver Bindings : Java, C#, Python, Ruby WebDriver API Simplified Architecture Selenium Server NOT needed * - Grid 2
    11. 11. Selenium ServerReplicate Selenium RC functionalitiesSelenium Grid 2
    12. 12. First stepsJava / C# bindingsSelenium ServerAndroid APKhttp://code.google.com/p/selenium/downloads/listChrome Driverhttp://code.google.com/p/chromium/downloads/listRubygem install selenium-webdriverPythonpip install selenium / easy_install selenium
    13. 13. Let’s code!
    14. 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"));
    15. 15. Page interactionswebElement.click()webElement.sendKeys(...)webElement.submit()Actions class Mouse Events / Drag and Drop
    16. 16. AJAX applicationsDOM Elements loaded asynchronouslya) Polling the DOM for n secondswebDriver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); (Java)webDriver.manage.timeouts.implicit_wait = 30 (Ruby)webDriver.implicit_wait(30) (Python)b) Wait until condition occursExpectedCondition / WebDriverWait
    17. 17. Testing style and executing JSTesting CSS propertieswebElement.getCssValue(“height”);webElement.getCssValue(“background-image”);Javascript executionJavascriptExecutor js = (JavascriptExecutor) webDriver;Long value = (Long) js.executeScript("return window.scrollY");
    18. 18. TargetLocator and Navigation InterfacesTargetLocator Frames and Popup DialogsTargetLocator target = webDriver.switchTo();WebElement element = target.frame(“name”)Alert alert = target.alert();Navigation Browser buttons emulationNavigation nav = webDriver.navigate();nav.back(); / nav.forward(); nav.to(“url”);
    19. 19. Migrating from Selenium 1Selenium 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. 20. Page Object Pattern / PageFactoryPages as ObjectsSeparation between DOM and services in a PageWebDriver API not exposedPageFactory class to easily instantiate a Page Object
    21. 21. Selenium Grid 2Starting Hub java -jar selenium-server-standalone-2.9.0.jar -role hubStarting WebDriver Node java -jar selenium-server-standalone-2.9.0.jar -role webdriver -hub http://localhost:4444/grid/register -browserbrowserName=chrome,version=15,platform=MAC -port 5556Grid consolehttp://localhost:4444/grid/consoleLaunching Test Remotely (Java)
    22. 22. Mobile Testing
    23. 23. Selenium 2 - Java QuickStart Archetypehttps://github.com/sebarmeli/Selenium2-Java-QuickStart-Archetype
    24. 24. Resourceshttp://www.slideshare.net/sebarmeli/getting-started-with-selenium-2https://github.com/sebarmeli/Selenium2-Java-Demohttp://seleniumhq.org/http://code.google.com/p/selenium/Google Groups
    25. 25. Questions ?
    1. Gostou de algum slide específico?

      Recortar slides é uma maneira fácil de colecionar informações para acessar mais tarde.

    ×