NoVaTAIG  April 7, 2010 Automated In-Browser Testing with Cucumber and Watir Rudy Regner Mike Perz Erik Scheirer Rasik Pan...
Our Situation <ul><li>Writing regression tests for an app in production </li></ul><ul><ul><li>Only required to support IE ...
Our Learning Curve <ul><li>Started with Watir </li></ul><ul><ul><li>Easy to get up and running </li></ul></ul><ul><li>Adde...
 
Once we switched back to Watir <ul><li>At first our tests were dependent on each other </li></ul><ul><ul><li>They needed t...
Code Samples <ul><li>Cucumber  </li></ul><ul><ul><li>feature file </li></ul></ul><ul><ul><li>Background </li></ul></ul><ul...
Interesting side benefits to writing automated tests <ul><li>Writing automated tests helped/made us understand the app bet...
Other useful tools <ul><li>Watircuke </li></ul><ul><li>IE Developer Toolbar </li></ul><ul><li>Firebug </li></ul><ul><li>Fi...
Cucumber as the common artifact
Ideal BDD Process: <ul><li>1. Describe behaviour in plain text </li></ul><ul><li>2. Write a step definition in cucumber </...
Performance: <ul><li>Since it takes 3 hours to run a test suite we should investigate using spork and --drb and testjour t...
Test Web apps in any language:  Drive a full or headless browser using one of these  <ul><li>*Webrat – Ruby acceptance tes...
Examples of Cucumber being used in the real world across various languages/platforms to test all sorts of things . <ul><li...
Upcoming SlideShare
Loading in …5
×

No Va Taig April 7 2010

1,300 views

Published on

presented to the Northern Virginia Test Automation Interest Group April 7, 2010

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,300
On SlideShare
0
From Embeds
0
Number of Embeds
10
Actions
Shares
0
Downloads
2
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • *(saves having to re-login each time)
  • With Selenium, … (open file) (open Watir)
  • Add screenshots
  • No Va Taig April 7 2010

    1. 1. NoVaTAIG April 7, 2010 Automated In-Browser Testing with Cucumber and Watir Rudy Regner Mike Perz Erik Scheirer Rasik Pandey
    2. 2. Our Situation <ul><li>Writing regression tests for an app in production </li></ul><ul><ul><li>Only required to support IE </li></ul></ul><ul><li>Rails v1.2.3 </li></ul><ul><ul><li>Precludes using Webrat latest version </li></ul></ul><ul><ul><li>?? Could possibly have used earlier version ?? </li></ul></ul><ul><li>why regression tests for earmarks? </li></ul><ul><ul><li>Bug made it through manual testing </li></ul></ul><ul><ul><li>Encapsulate critical functionality in automated regression test scripts to decrease likelihood of this failure occuring again. </li></ul></ul>
    3. 3. Our Learning Curve <ul><li>Started with Watir </li></ul><ul><ul><li>Easy to get up and running </li></ul></ul><ul><li>Added Cucumber (RSpec) </li></ul><ul><li>Replaced Watir with Webrat and Selenium </li></ul><ul><ul><li>Sought flexibility gain through re-use of Webrat to drive Selenium, Mechanize or straight Rails </li></ul></ul><ul><li>Productivity dropped with Selenium </li></ul><ul><ul><li>Script debugging difficult without irb </li></ul></ul><ul><ul><ul><li>You can attach to an browser window* (with Watir) </li></ul></ul></ul><ul><ul><li>Watir can manipulate the DOM as objects. (you can iterate through the cells of an html table) </li></ul></ul><ul><ul><li>With Selenium you would have to find each cell individually. </li></ul></ul><ul><li>Converted existing Selenium code to Watir </li></ul>
    4. 5. Once we switched back to Watir <ul><li>At first our tests were dependent on each other </li></ul><ul><ul><li>They needed to be run in a particular order. </li></ul></ul><ul><ul><li>We used Rake to accomplish this. </li></ul></ul><ul><ul><ul><li>Open 4 browsers with 4 different users (Watir::IE.new_process vs. Watir::IE.new) </li></ul></ul></ul><ul><ul><li>Now we can attach Watir to whichever browser session we need </li></ul></ul><ul><ul><ul><li>Watir::IE.attach </li></ul></ul></ul><ul><ul><li>We use SQLite to keep track of which user is associated with which browser session </li></ul></ul>
    5. 6. Code Samples <ul><li>Cucumber </li></ul><ul><ul><li>feature file </li></ul></ul><ul><ul><li>Background </li></ul></ul><ul><ul><li>Scenarios </li></ul></ul><ul><ul><li>Scenario Outline (tables) </li></ul></ul><ul><li>Webrat </li></ul><ul><li>Watircuke </li></ul><ul><li>Selenium </li></ul><ul><li>Step Definitions </li></ul>
    6. 7. Interesting side benefits to writing automated tests <ul><li>Writing automated tests helped/made us understand the app better. </li></ul><ul><li>Found application bugs that were missed earlier </li></ul>
    7. 8. Other useful tools <ul><li>Watircuke </li></ul><ul><li>IE Developer Toolbar </li></ul><ul><li>Firebug </li></ul><ul><li>FireWatir recorder:  www.itest2.com/downloads </li></ul>
    8. 9. Cucumber as the common artifact
    9. 10. Ideal BDD Process: <ul><li>1. Describe behaviour in plain text </li></ul><ul><li>2. Write a step definition in cucumber </li></ul><ul><li>3. Run and watch it fail </li></ul><ul><li>4. Write code to make the step pass </li></ul><ul><li>5. Run again and see the step pass </li></ul><ul><li>6. Repeat 2-5 for all your functionality </li></ul>
    10. 11. Performance: <ul><li>Since it takes 3 hours to run a test suite we should investigate using spork and --drb and testjour to distribute the test load if possible to speed up test runs. </li></ul>
    11. 12. Test Web apps in any language: Drive a full or headless browser using one of these <ul><li>*Webrat – Ruby acceptance testing for web applications </li></ul><ul><li>*Capybara – Acceptance testing framework with a webrat-like API and support for multiple backends, including RackTest, Selenium, Celerity and Culerity </li></ul><ul><li>*Steam – Drives a fast headless browser with Javascript support. Support for the normal webrat step definitions, see Setting up Steam </li></ul><ul><li>*Testing PHP app using Webrat </li></ul><ul><li>*WebDriver – Drives IE, Firefox, Chrome </li></ul><ul><li>*Watir – Drives IE (Windows only), see: Setting up FireWatir </li></ul><ul><li>*FireWatir – Drives Firefox on Windows, OSX and GNU/Linux </li></ul><ul><li>*SafariWatir – Drives Safari (OS X only) </li></ul><ul><li>*ChromeWatir – Drives Google Chrome </li></ul><ul><li>*Celerity – Drives a fast headless browser with Javascript support. Examples here </li></ul><ul><li>*Culerity – For when you can’t run your app under jRuby </li></ul><ul><li>*Selenium – Runs any browser (any OS), see: Setting up Selenium </li></ul><ul><li>*Mechanize – Runs a headless browser (any OS) </li></ul>
    12. 13. Examples of Cucumber being used in the real world across various languages/platforms to test all sorts of things . <ul><li>http://wiki.github.com/aslakhellesoy/cucumber/tutorials-and-related-blog-posts </li></ul>

    ×