Getting started with Selenium 2
Upcoming SlideShare
Loading in...5
×
 

Getting started with Selenium 2

on

  • 8,766 views

Presented at OSDC 2011, Canberra, Australia

Presented at OSDC 2011, Canberra, Australia

Statistics

Views

Total Views
8,766
Views on SlideShare
8,703
Embed Views
63

Actions

Likes
11
Downloads
558
Comments
0

6 Embeds 63

http://osdc.com.au 32
http://2011.osdc.com.au 21
http://www.linkedin.com 5
http://a0.twimg.com 3
http://www.scoop.it 1
https://www.linkedin.com 1

Accessibility

Upload Details

Uploaded via as Apple Keynote

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • \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

Getting started with Selenium 2 Getting started with Selenium 2 Presentation Transcript

  • Getting started with Selenium 2 Sebastiano Armeli-Battana @sebarmeli https://github.com/sebarmeliNovember 17 , 2011 Open Source Developers Conference, Canberra
  • What is Selenium?Open Source Web Application Testing SystemAutomated UI TestingFunctional type of testsMultiple browsers, multiple languages
  • 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) Server : Proxy to launch browsers Client libraries
  • SeleniumSelenium 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 APIHtmlUnitDriverJava bindings
  • Selenium 2 - IDE - Web Driver Bindings : Java, C#, Python, Ruby WebDriver API Simplified Architecture Selenium Server NOT needed * - Grid 2
  • Selenium ServerReplicate Selenium RC functionalitiesSelenium Grid 2
  • 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
  • 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 interactionswebElement.click()webElement.sendKeys(...)webElement.submit()Actions class Mouse Events / Drag and Drop
  • 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
  • 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");
  • 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”);
  • 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();
  • Page Object Pattern / PageFactoryPages as ObjectsSeparation between DOM and services in a PageWebDriver API not exposedPageFactory class to easily instantiate a Page Object
  • 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)
  • 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-Demohttp://seleniumhq.org/http://code.google.com/p/selenium/Google Groups
  • Questions ?