Automated UI testing. Selenium Yuriy Gerasimov [email_address] Skype yuriy_gerasimov Twitter ygerasimov
What is Selenium? <ul><li>Selenium IDE
Selenium RC
Selenium Grid
Selenium 2 (Webdriver) </li></ul>
Selenium IDE <ul><li>Addon to Firefox
Easy to start using
Can record tests in PHP
Demo </li></ul>
Selenium RC <ul><li>Run in multiple browsers in Virtual Boxes
Runs tests via Javascript </li></ul>
Selenium RC <ul><li>To install Selenium RC download java server from http://seleniumhq.org/download
Run Selenium IDE tests via PHPUnit  </li><ul><li>Ubuntu: apt-get install phpunit
If php 5.2 make a preference for karmic like for php </li></ul><li>Demo </li></ul>
Upcoming SlideShare
Loading in...5
×

Automated UI testing with Selenium

11,225

Published on

Presentation from DrupalCafe Kyiv 19 May 2011 about introducing Selenium to testing of Drupal.

Published in: Technology
0 Comments
5 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
11,225
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
133
Comments
0
Likes
5
Embeds 0
No embeds

No notes for slide

Automated UI testing with Selenium

  1. 1. Automated UI testing. Selenium Yuriy Gerasimov [email_address] Skype yuriy_gerasimov Twitter ygerasimov
  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 IDE <ul><li>Addon to Firefox
  7. 7. Easy to start using
  8. 8. Can record tests in PHP
  9. 9. Demo </li></ul>
  10. 10. Selenium RC <ul><li>Run in multiple browsers in Virtual Boxes
  11. 11. Runs tests via Javascript </li></ul>
  12. 12. Selenium RC <ul><li>To install Selenium RC download java server from http://seleniumhq.org/download
  13. 13. Run Selenium IDE tests via PHPUnit </li><ul><li>Ubuntu: apt-get install phpunit
  14. 14. If php 5.2 make a preference for karmic like for php </li></ul><li>Demo </li></ul>
  15. 15. Selenium 2 Webdriver <ul><li>Communicate with browsers in 'native' way via drivers
  16. 16. Not limited to javascripts. For example: upload files, work with popups, iframes etc.
  17. 17. Support for a lot of browsers including mobile phone browsers
  18. 18. PHPUnit libraries: https://github.com/chibimagic/WebDriver-PHP </li></ul>
  19. 19. Selenium2 Webdriver and Drupal <ul><li>How to integrate to simpletest </li><ul><li>In order to get into sandbox we need to set headers
  20. 20. This is possible with Firefox only (send custom profile to Selenium) </li></ul><li>http://drupal.org/project/selenium
  21. 21. Demo </li></ul>
  22. 22. Drupal tests API <ul><li>Main class DrupalSeleniumWebTestCase
  23. 23. Init driver as connection to Selenium server
  24. 24. Already implemented methods: </li><ul><li>drupalOpenUrl, drupalLogin, drupalLogout, verboseScreenshot ... </li></ul><li>class SeleniumWebElement (sendKeys, click, submit, getText...) </li></ul>
  25. 25. Selenium 2 locators <ul><li>css, id, name, class, link, xpath </li></ul>
  26. 26. Drag and drop example
  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 (h ttp://en.wikipedia.org/wiki/Xvfb).
  28. 28. Before we start Selenium server we need to start Xvfb.
  29. 29. Run tests from shell:
  30. 30. sudo -u www-data php ./scripts/run-tests.sh --url http://URL --class SeleniumTestExample </li></ul>
  31. 31. Future <ul><li>Implement methods from DrupalWebTestCase
  32. 32. Start using Selenium in testing contrib modules and core (module draggableviews already have selenium test) </li></ul>
  33. 33. References <ul><li>Selenium RC supported browsers h ttp://www.seleniumwiki.com/software-testing/selenium-supported-browsers
  34. 34. PHPUnit documentation about Selenium h ttp://www.phpunit.de/manual/3.5/en/selenium.html#selenium.selenium-rc
  35. 35. http://ygerasimov.com/integrating-selenium-to-drupal-simpletest-framework
  36. 36. http://ygerasimov.com/run-selenium-tests-drupal-on-debian-headless
  37. 37. http://ygerasimov.com/drupal-selenium-tests-api </li></ul>
  38. 38. Automated UI testing. Selenium Yuriy Gerasimov [email_address] Skype yuriy_gerasimov Twitter ygerasimov
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×