Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Mobile Test Automation using one API and one infrastructure

813 views

Published on

Presentation at Mobile App Europe Conference, Potsdam Germany October 2014.

Published in: Software
  • Be the first to comment

Mobile Test Automation using one API and one infrastructure

  1. 1. 30.09.2014 1 MOBILE TEST AUTOMATION SELENIUM SELENDROID IOS-DRIVER
  2. 2. AGENDA ● Welcome ● Selenium Crash Course ● ios-driver + Selendroid ● Building a cross platform infrastructure 2
  3. 3. WHO AM I ? 3 Gridfusion Software Solutions Michael Palotas Dipl. Ing. (FH) Nachrichtentechnik Email: michael.palotas@gridfusion.net LinkedIn: http://ch.linkedin.com/in/michaelpalotas/ Xing: https://www.xing.com/profile/Michael_Palotas Twitter: @michael_palotas Kontakt: Gerbiweg 2 8853 Lachen SWITZERLAND Tel.: +41 79 6690708 Founder / Principal Consultant Gridfusion Software Solutions Head of Productivity & Test Engineering eBay International
  4. 4. WARM-UP 4 Why do you automate tests? Which tests should be automated? Who should automate? What is different about mobile?
  5. 5. DISCLAIMER 5 THIS IS NOT A SELENDROID OR IOS-DRIVER TRAINING
  6. 6. MOBILE TEST AUTOMATION 6 Not as mature as web automation Immature tools market Tools are usually platform specific Multi code base
  7. 7. EMULATORS VS. DEVICES 7 What to test where?
  8. 8. SAME AUTOMATION CODE BETWEEN PLATFORMS? 8 Sounds good first but Most apps are different between platforms Different element locator strategy Do reuse the helper functions
  9. 9. TEST INFRASTRUCTURE 9 AUT API DB Browsers Mobiles
  10. 10. 2. SELENIUM 10
  11. 11. A LITTLE SELENIUM HISTORY Selenium was so named because Huggins, dissatisfied with testing tools on the market, was seeking a name that would position the product as an alternative to Mercury Interactive QuickTest Professional commercial testing software. The name, Selenium, was selected because selenium mineral supplements serve as a cure for mercury poisoning, Huggins explained. 11
  12. 12. WHAT IS SELENIUM? 12 SELENIUM AUTOMATES BROWSERS THAT'S IT ... One more thing ... Selenium is becoming a W3C standard: http://www.w3.org/TR/webdriver
  13. 13. WHAT IS SELENIUM? 13 Protocol which describes user interactions Supports most browsers Supports most programming languages
  14. 14. SELENIUM – WHAT IT IS NOT 14 a drag & drop tool a network testing / monitoring tool a performance testing tool a reporting tool a testcase management tool
  15. 15. WHY OPEN SOURCE? 15 It is free (…) Independent of 3rd parties Faster innovation cycles Motivated employees Easier hiring
  16. 16. THE SELENIUM „FLAVORS“ 16 Selenium IDE Selenium Selenium GRID Let’s forget about this one real quick
  17. 17. 5. WEBDRIVER PROTOCOL 17
  18. 18. SELENIUM 2 / WEBDRIVER 18 JSON WIRE PROTOCOL Client Java C# Ruby Python Server Server Server i.e. Selendroid, iOS-Driver
  19. 19. SELENIUM CLIENT 19 Is seen as Selenium by the users Generates HTTP request, which are received by the server Is called by the test framework or the CI server Supported languages: Java, C#, Python, Ruby, Perl, PHP, JS
  20. 20. SELENIUM SERVER 20 Receives HTTP requests from server Start and teardown of browser Translates requests into browser specific commands Communicates back to the client
  21. 21. 6. SELENIUM BASICS 21
  22. 22. DOWNLOADS - http://www.seleniumhq.org/ - http://selenium.googlecode.com/files/ selenium-server-standalone-2.42.2.jar - Maven example: 22
  23. 23. DRIVER 23 Each browser has its own driver Firefox driver is part of the standalone jar http://selenium.googlecode.com/files/selenium-server-standalone-2.42.2.jar Chrome: https://code.google.com/p/selenium/wiki/ChromeDriver Opera: https://code.google.com/p/selenium/wiki/OperaDriver Internet Explorer: https://code.google.com/p/selenium/wiki/ InternetExplorerDriver
  24. 24. DRIVER Each driver implements the JSON Wire Protocol Driver interacts with the browser (or mobile) CLIENT SERVER 24 JSON Wire Protocol BROWSER DRIVER
  25. 25. OUR FIRST TEST Open a Firefox Browser Go to http://gridfusion.net Close the browser @Test public void myFirstTest() { WebDriver driver = new FirefoxDriver(); driver.get("http://gridfusion.net"); driver.quit(); } 25
  26. 26. DRIVER API 26
  27. 27. PAGE TITLE Open a Firefox browser Go to http://gridfusion.net Print the page title in the console Close the browser @Test public void pageTitleTest() { WebDriver driver = new FirefoxDriver(); driver.get("http://gridfusion.net"); String pageTitle = driver.getTitle(); System.out.println(pageTitle); driver.quit(); } 27
  28. 28. ASSERTS Open a Firefox Browser Go to: http://gridfusion.net Verify Page Title = GRIDFUSION.net – Home Close the browser 28
  29. 29. WEBELEMENT 29 Represents an HTML Element Interactions on a page happen via WebElement http://selenium.googlecode.com/svn/trunk/docs/api/java/org/openqa/selenium/WebElement.html
  30. 30. LOCATORS id cssSelector linkText name partialLinkText tagName xpath 30 driver.findElement(By.XYZ)
  31. 31. 7. REMOTE WEBDRIVER 31
  32. 32. REMOTE WEBDRIVER Decouples tests from browsers WebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), DesiredCapabilities); 32 Machine 1 Eclipse TestNG CI Machine 2 HTTP Browser
  33. 33. DESIRED CAPABILITIES - BROWSER 33 DesiredCapabilities capability = new DesiredCapabilities(); capability.setBrowserName(“firefox”); https://code.google.com/p/selenium/wiki/DesiredCapabilities
  34. 34. REMOTEWEBDRIVER ● Start a selenium server: 34 ● java –jar selenium-server-standalone-2.42.2.jar ● Use RemoteWebDriver and set DesiredCapabilities to Firefox ● Open a Firefox browser ● Go to: http://gridfusion.net ● Close the browser @Test public void remoteWebdriverFireFoxTest() throws MalformedURLException { DesiredCapabilities capability = DesiredCapabilities.firefox(); WebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), capability); driver.get("http://gridfusion.net"); driver.quit(); }
  35. 35. 8. SELENIUM GRID 35
  36. 36. WHY SELENIUM GRID? 36 Environment Management & Control Scaling Parallel execution of tests Reduction of execution times Crossover tests (web, mobile)
  37. 37. SELENIUM GRID 37 SEQUENTIAL EXECUTION TEST TEST TEST TEST TIME n PARALLEL EXECUTION TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TIME n
  38. 38. SCALING – SELENIUM GRID 38 DEV CI …. SELENIUM GRID HUB IOS ANDROID WINDOWS LINUX OSX
  39. 39. 1. STEP– START THE GRID HUB 39 Open a new terminal window Start the Selenium GRID hub by typing: java -jar selenium-server-standalone-2.42.jar -role hub Enter http://localhost:4444/grid/console into the browser
  40. 40. 2. STEP– REGISTER A NODE 40 Open a second terminal window Start and register a Selenium node by entering: java -jar selenium-server-standalone-x.y.z.jar –role wd -hub http://localhost:4444/grid/register
  41. 41. SELENIUM NODE – STANDARD CONFIG - Go to: http://localhost:4444/grid/console Standard Configuration: 5 Firefox 5 Chrome 1 Internet Explorer 41
  42. 42. SCREENSHOTS 42
  43. 43. 10. REPORTING 43
  44. 44. STANDARD REPORTS - TestNG reports are put into: **/test-output - Look for: emailable-report.html 44
  45. 45. CUSTOM REPORTING - By calling Reporter.log(“your log message”), you can add additional information to the report 45
  46. 46. SCREENSHOTS - Screenshots can also be placed directly into the report 46
  47. 47. 12. MOBILE AUTOMATION 47
  48. 48. SELENIUM 2 / WEBDRIVER 48 JSON WIRE PROTOCOL Client Java C# Ruby Python Server Server Server i.e. Selendroid, iOS-Driver
  49. 49. (SOME) MOBILE AUTOMATION REQUIREMENTS * Reuse of the existing Selenium infrastructure for the web * Implementation of the Selenium protocol (JSON wire protocol) * The application under test (aut) should not need to be modified * Support for emulators/simulators as well as real devices * Parallel execution of tests in a Selenium Grid * Management of multiple applications, versions, languages * Support for runtime inspection for the app * Hybrid app support * No jailbreaking of device required 49
  50. 50. IOS-DRIVER + SELENDROID 50 IOS: http://ios-driver.github.io/ios-driver/index.html ANDROID: http://selendroid.io/ Both projects implement the Webdriver API (JSON Wire Protocol)
  51. 51. ANDROID: MOBILE WEB 51
  52. 52. ANDROID: NATIVE APP 52
  53. 53. IOS: MOBILE WEB 53
  54. 54. WRITE ONCE RUN EVERYWHERE 54
  55. 55. WRITE ONCE RUN EVERYWHERE 55
  56. 56. INSPECTOR 56
  57. 57. SAUCELABS CLOUD 57
  58. 58. WHAT HAVE YOU LEARNED TODAY? 58
  59. 59. 59 THANK YOU

×