Using Selenium to Test Native Apps (Wait, you can do that?)

13,310 views

Published on

Published in: Technology

Using Selenium to Test Native Apps (Wait, you can do that?)

  1. 1. Using Selenium to Test NativeApplications …wait, you can do that?
  2. 2. Hi.I’m JASON CARR. I work at sauce LABS.
  3. 3. @maudineormsby …it’s a long story.
  4. 4. I’m a developerand contributor to selenium and appium
  5. 5. This talk is about…
  6. 6. This talk is about…the problem of ios app automation
  7. 7. This talk is about…lessons learned automating apps
  8. 8. This talk is about…the right approach to testing native apps
  9. 9. This talk is about…the tools available to test your apps today
  10. 10. This talk is about…WHAT HOPE WE HAVE FOR THE FUTURE.
  11. 11. the problem of ios app automation
  12. 12. “…a bit like being dropped off in afield somewhere with no map,tools or supplies and being toldyou need to build a house.” -Alex Vollmer
  13. 13. js js Instruments.app Instruments.app App
  14. 14. js js Instruments.app Instruments.app App client device
  15. 15. UI Automation only runs in Instruments.app
  16. 16. Tests have to be in Javascript
  17. 17. No realtime interaction with tests
  18. 18. Hard to reuse code
  19. 19. One test at a time
  20. 20. So what have we learned so far?
  21. 21. Two attempted approaches to automation
  22. 22. Script/ Script/ App Screen Capture Screen CaptureFramework Framework client device
  23. 23. Hard to abstract
  24. 24. Very brittle
  25. 25. Hard to use with real devices
  26. 26. Hard to use with CI or parallelize
  27. 27. script script Client library Client library App client device
  28. 28. Requires code modification
  29. 29. Real devices are hard
  30. 30. New framework and new tests
  31. 31. The right way to automate ios
  32. 32. Remember the testing pyramid
  33. 33. Are you writing unit tests for apps? It’s not that hard!
  34. 34. Test your views appropriately
  35. 35. For UIWebViews use iWebDriver
  36. 36. Yes, yes, but now what?
  37. 37. Code reuse is good.
  38. 38. Realtime interaction
  39. 39. Integrate with existing automation
  40. 40. Parallel tests and real devices
  41. 41. That sounds great, but how?
  42. 42. Appium
  43. 43. Open SourceCan be extended
  44. 44. Uses webdriver APIRuns with off-the-shelf client libraries Language agnostic
  45. 45. Real timeInteract with js interpreter or client
  46. 46. Real devices
  47. 47. Works in parallel (architecturally)
  48. 48. No code modification
  49. 49. test script test script AppAppium Server Appium Server Instruments.app Instruments.app client device
  50. 50. Easy to get started
  51. 51. Clone Appium
  52. 52. pip install bottle
  53. 53. python server.py /path/to/my.app
  54. 54. from selenium import webdrivercommand_url = “http://localhost:4723/wd/hub”iphone = webdriver.DesiredCapabilities.IPHONEdriver = webdriver.Remote(command_url, iphone)fields = driver.find_elements_by_tag_name(textField’)fields[0].send_keys(3)fields[1].send_keys(4)buttons = driver.find_elements_by_tag_name(button’)buttons[0].click()
  55. 55. demo
  56. 56. Doesn’t support execute_script() …yet. More on this later.
  57. 57. 1 Second delay between commands UI Automation limitation
  58. 58. Still uses UIAutomation ‘Accessibility’ is important
  59. 59. where do we go from here?
  60. 60. Implement more of the API
  61. 61. WebKit remote debugging protocol
  62. 62. Selenium Grid support
  63. 63. Questions? Thank you!
  64. 64. ResourcesAppium Github Repo:http://goo.gl/4E5F0Dan Cuellar’s talk on Appium:http://goo.gl/qgLhaFrançois Reynaud on ios-driver:http://goo.gl/pzn75Simon Stewart’s blog on mobiletesting:http://goo.gl/8wl8j

×