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.

Automated ui testing with selenium. drupal con london 2011

0 views

Published on

DrupalCon London 2011 Selenium UI Testing

Published in: Technology
  • Be the first to comment

Automated ui testing with selenium. drupal con london 2011

  1. 1. Automated UI testing with Selenium Yuriy Gerasimov Email: yuri.gerasimov@gmail.com Twitter: ygerasimov IRC/d.o: ygerasimov Web: ygerasimov.com
  2. 2. What is Selenium? <ul><li>Selenium IDE
  3. 3. Selenium RC
  4. 4. Selenium Grid
  5. 5. Selenium 2 (Webdriver) </li></ul>
  6. 6. Selenium 2 Webdriver <ul><li>Communicate with browsers in 'native' way via drivers
  7. 7. Not limited to javascripts. For example: upload files, work with popups, iframes etc.
  8. 8. Support for a lot of browsers including mobile phone browsers
  9. 9. PHPUnit libraries: https://github.com/chibimagic/WebDriver-PHP </li></ul>
  10. 10. Selenium2 and Drupal <ul><li>Simpletest. Change user agent headers.
  11. 11. Support for Firefox and Chrome
  12. 12. http://drupal.org/project/selenium </li></ul>
  13. 13. Tests API <ul><li>Main class DrupalSeleniumWebTestCase
  14. 14. Init driver as connection to Selenium server
  15. 15. Already implemented methods: </li><ul><li>drupalOpenUrl, drupalLogin, drupalLogout, verboseScreenshot … </li></ul><li>class SeleniumWebElement (sendKeys, click, submit, getText...) </li></ul>
  16. 16. Selenium 2 locators <ul>css, id, name, class, link, xpath </ul>
  17. 17. XPath vs CSS locators <ul><li>Selenium RC has sizzle
  18. 18. Webdriver uses native browsers CSS selectors.
  19. 19. CSS selectors are faster
  20. 20. XPath can go up
  21. 21. Example:
  22. 22. id('user1')/../../td[@class=&quot;actions&quot;]/a[@class=&quot;delete-user&quot;] </li></ul>
  23. 23. Important notes <ul><li>Selenium is for automating of manual testing
  24. 24. Can't interact with hidden elements
  25. 25. Sometimes browser is too fast. Remember to wait till javascript finishes its work.
  26. 26. Some differences in API between browsers (Chrome can't upload files, difference in work with selectboxes) </li></ul>
  27. 27. Run tests on headless server <ul><li>Key tool: Xvfb – X11 server that performs all graphical operations in memory, not showing any screen output (http://en.wikipedia.org/wiki/Xvfb). </li></ul>Before we start Selenium server we need to start Xvfb. Run tests from shell: <ul>sudo -u www-data php ./scripts/run-tests.sh --url http://URL --class SeleniumTestExample </ul>
  28. 28. Drupal core tests <ul><li>autocomplete
  29. 29. collapse
  30. 30. machine-name
  31. 31. states
  32. 32. tabledrag
  33. 33. tableheader </li></ul><ul><li>tableselect
  34. 34. textarea
  35. 35. vertical-tabs
  36. 36. upload </li></ul>
  37. 37. References <ul><li>http://seleniumhq.wordpress.com/
  38. 38. http://code.google.com/p/selenium/wiki/JsonWireProtocol
  39. 39. http://saucelabs.com/blog/
  40. 40. http://ygerasimov.com </li></ul>
  41. 41. Automated UI testing with Selenium Yuriy Gerasimov Email: yuri.gerasimov@gmail.com Twitter: ygerasimov IRC/d.o: ygerasimov Web: ygerasimov.com

×