Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Cross Browser Testing with Selenium

FEVR
December 18, 2014

Cross Browser Testing with Selenium

How to use selenium web driver for testing websites on different browser and different devices

FEVR

December 18, 2014
Tweet

More Decks by FEVR

Other Decks in Technology

Transcript

  1. TODAY FUNCTIONAL TEST OF WEB APP Multiple browser Multiple display

    dimensions (a.k.a. Responsive design) Mobile app Time consuming Error prone Booring!!!!
  2. BENEFITS OF AUTOMATIC FUNCTIONAL TESTING OF WEB APPLICATION Frequent regression

    testing Rapid feedback to developers Form of documentation for test cases, automatically generated, and up to date Custom defect reporting Finding defect missing by manual testing
  3. SELENIUM Created by Thoughworks in 2007 Now opensource Set of

    components for automated testing Custom defect reporting Used by Thoughworks, Facebook, Google, and many others
  4. OK, SO WHAT CAN I DO WITH WEBDRIVER? Open a

    web page in a real browser Change browser dimensions Interact with browser: click on link, upload file, fill input field, click on checkbox, etc Take web page's screenshots Get the page source
  5. SUPPORTED BROWSERS Internet Explorer 6, 7, 8, 9, 10 FireFox

    Safari Opera HtmlUnit phantomjs Android (with Selendroid or appium) iOS (with ios-driver or appium)
  6. HELLO WORLD SELENIUM // Create a new instance of the

    Firefox driver WebDriver driver = new FirefoxDriver(); // And now use this to visit Google driver.get("http://www.google.com"); // Find the text input element by its name WebElement element = driver.findElement(By.name("q")); // Enter something to search for element.sendKeys("Cheese!"); // Now submit the form. WebDriver will find the form for us from the element element.submit(); //Close the browser driver.quit();
  7. BAD PARTS!!! Tests are slow Flaky test It's just a

    driver!!! You'll write lots of boilerplate code
  8. TESTS ARE SLOW Parallelize: split long test in multiple small

    test Use the grid Luke!!!!!! Use the cloud Luke!!!!!! (https://saucelabs.com/)
  9. IT'S JUST A DRIVER Missing out of the box functional

    testing solution Need to put several pieces together: testing framework (junit), report framework (NGReport)
  10. BOILERPLATE CODE Automatic Functional Tests != Automatic Generation of Functional

    Tests Developers need to write boilerplate code, lot's of boilerplate code!!!!!!! Use PageObjects
  11. SUGGESTION FOR A SAFE START Start small, stay small: write

    tests for the most often used case, or small case, then gradually add other tests Use Page Objects Automatic Page Object Generation, after each build