Testing Grails Applications With Selenium Rc

5,220 views

Published on

Presentation on testing Grails applications using the Selenium RC Plugin given at the London Groovy & Grails User Group on 20th Nov 2009

0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
5,220
On SlideShare
0
From Embeds
0
Number of Embeds
442
Actions
Shares
0
Downloads
137
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide
  • Comparison with webtest/g-func Comparison with Selenium IDE Test examples Running tests Browsers Page Objects Data Driving Spock/BDD
  • Show example suite run
  • Selenese not a 'real' language Sequence, Selection & Iteration (1 out of 3) No encapsulation / modularity
  • Selenese tests as a 'run-on sentence' divide into methods simpler modularity (no custom commands) leads into… less repetition… page object pattern Bits of coverage hide in long tests Temptation to extend tests
  • What is a page object? exposes methods that reflect the things the user can see and do on a page eliminate duplication by building abstractions hides the detail of how code completion tests responsible for assertions, not page object Underlying implementation can be changed
  • Note does not extend or mixin Selenium test classes
  • shows how page object hide detail of implementation Page object handles position of elements in table, test can access by name
  • Factory method that opens URL Navigation method that returns another page object Scrapes error messages and returns in useful form Returns element value if present (can't do in Selenese) Uses MOP to override property access to type in form fields
  • using monolithic data setup Build test data Fixtures tearDown
  • withTransaction blocks ensure data committed and errors thrown right away Importance of tearDown
  • Testing Grails Applications With Selenium Rc

    1. 1. Testing Grails Applications with Selenium RC Rob Fletcher, Energized Work
    2. 2. Running Selenium RC Tests grails install-plugin selenium-rc grails test-app grails test-app -functional
    3. 3. Browsers grails -Dselenium.browser=*firefox test-app
    4. 4. Selenium RC vs. Selenium IDE
    5. 5. Better Factored Tests
    6. 6. Writing Selenium RC Tests <ul><ul><li>Use @Mixin(SeleniumTest) </li></ul></ul><ul><ul><ul><li>Simple
    7. 7. Works with non-JUnit frameworks </li></ul></ul></ul><ul><ul><li>Extend GrailsSeleniumTestCase </li></ul></ul><ul><ul><ul><li>Offers Selenese-like assertions, e.g. assertTextPresent
    8. 8. Easy migration from Selenese </li></ul></ul></ul><ul><ul><li>Use Page Object Pattern </li></ul></ul><ul><ul><ul><li>Tests do not interact directly with Selenium </li></ul></ul></ul>
    9. 9. The Page Object Pattern
    10. 10. Page Object Test Example
    11. 13. Data Driving
    12. 14. Using Build-Test-Data
    13. 15. BDD Frameworks
    14. 16. Selenium RC & Spock
    15. 17. rfletcherEW adhockery.blogspot.com energizedwork.com github.com/robfletcher/grails-selenium-rc

    ×