Test web applications wisely with open source test frameworks: Watir and Selenium WebDriver

While few people deny the benefits of test automation, comprehensive automated testing via UI (browser for web applications) is rarely implemented in software projects. Common reasons for projects' failed attempts on test automation are:

  • Difficult to learn - test scripts are complex and testing tools are not easy to use
  • Hard to maintain - UI tests are vulnerable to application changes
  • Long feedback loop - automated tests take too long to run

To succeed in automated testing via UI, software projects need to overcome all these 3 challenges.

This book presents a practical approach to implementing test automation for web applications. Topics include:

  • Developing easy to read and maintain Watir/Selenium tests using next-generation functional testing tool
  • Page object model
  • Functional Testing Refactorings
  • Cross-browser testing against IE, Firefox and Chrome
  • Setting up continuous testing server to manage execution of a large number of automated UI tests
  • Requirement traceability matrix
  • Strategies on team collaboration and test automation adoption in projects and organizations

To help readers learn more effectively, the book has a dedicated site containing the following resources:

  • Software. Test automation is not necessarily expensive. All test frameworks featured in this book are free and open-source.
  • Sample test scripts. Ready-to-run test scripts for the exercises in the book.
  • Demo web sites. Two demo sites were created for readers to try out test scripts.
  • Tutorial screencasts. You will be able to see how excercies are done step by step.

Zhimin Zhan

Zhimin Zhan is the founder and Continuous Integration Officer of AgileWay Pty Ltd, Australia. As an advisor and coach, he helps organzations by implementing test automation with Continuous Integration using open technologies such as Selenium WebDriver and Watir. Zhimin is the creator of TestWise, the next-generation functional testing tool that supports functional test refactorings, and frequent speaker and writer. He shares his test automation and CI experience at testwisely.com.

  • Preface

    • Who should read this book?

    • How to read this book?

    • What’s inside the book?

    • Test scripts, Screencasts and Other resources

    • Send Me Feedback

    • Acknowledgements

  • 1. What is Web Test Automation?

    • Test Automation Benefits

    • Reality Check

    • Reasons for Test Automation Failures

    • Successful Web Test Automation

    • Learning Approach

    • Next Action

  • 2. First Automated Test

    • Test Design

    • Installing TestWise (about 2 minutes)

    • Create a Test

    • Create Test Case From Recorded Test Steps

    • Run test in IE

    • When a test failed…

    • Wrap up

  • 3. How Automated Testing works

    • Web Test Drivers

    • Automated Testing Rhythm

    • Test Frameworks

    • Run Tests From Command Line

  • 4. TestWise - Functional Testing IDE

    • Philosophy of TestWise

    • TestWise Project Structure

    • Test Execution

    • Keyboard Navigation

    • Snippets

    • Script Library

    • Test Refactoring

    • Wrap Up

  • 5. Case Study

    • Test Site

    • Preparation

    • Create Test Project

    • Test Suite: Sign in

    • Test Suite: Select Flights

    • Enter Passenger Details

    • Book confirmation after payment

    • Run all tests

    • Wrap Up

  • 6. Test Automation Characteristics

    • Specific

    • Clean

    • Independent

    • Frequent

    • Focused

    • Programmable

    • Creative

    • Sustainable

    • Wrap Up

  • 7. Maintainable Functional Test Design

    • Record/Playback Leads to Unmaintainable Test Scripts

    • Success Criteria

    • Maintainable Automated Test Design

    • Maintain with Ease

    • Case Study: Refine Test Scripts

    • Wrap Up

  • 8. Functional Test Refactoring

    • Code Refactoring

    • Functional Test Refactoring

    • Tool Support

    • Case Study

    • Summary

  • 9. Review

    • Syntax Errors

    • Set up source control

    • GUI/Object Map

    • Custom Libraries

    • Debugging

  • 10. Collaboration

    • Pre-requisite

    • Scenario 1: “It worked on my machine”

    • Scenario 2: Synergy

    • Scenario 3: Acceptance Test Driven Development

    • Wrap up

  • 11. Continuous Integration with Functional Tests

    • Long feedback loop

    • Continuous Integration

    • Continuous Integration and Testing

    • CI Build Steps

    • Functional UI Test Build Step with Rake

    • Set up a continuous testing server: BuildWise

    • Review

    • Dynamic Build Process

  • 12. Test Reporting

    • Reporting Automated Test Results

    • Defect Tracking

    • Requirement Traceability

  • 13. Selenium

    • Selenium Framework

    • Case Study: Switch RWebSpec to use Selenium

    • Run in Firefox on Mac

    • Case Study: Selenium-WebDriver and RSpec

    • Cross Browser Functional Testing

    • Comparison: Selenium and Watir

  • 14. Cucumber

    • Cucumber Framework

    • Case Study: Selenium and Cucumber

    • Comparison: RSpec and Cucumber

    • RSpec and Cucumber Co-exists

  • 15. Adopting Test Automation

    • Seek Executive Sponsorship

    • Choose Test Framework

    • Select Test Tool

    • Find a Mentor

    • Manage Expectation

    • Solo Test Automation

    • Common Mistakes

    • Wrap up

  • Appendix 1 Functional Test Refactoring Catalog

    • Move Test Scripts

    • Extract Function

    • Extract to Page Class

    • Introduce Page Object

    • Rename

  • Appendix 2 Test Automation in ClinicWise project

    • Build Stats

    • Stage 1: Write automated tests on the first day

    • Stage 2: Set up CI server within the first week

    • Stage 3: Release to production early

    • Stage 4: Release often (daily)

    • Stage 5: Set up parallel test execution in CI

    • Questions and Answers

  • Resources

    • Books

    • Web Sites

    • Tools

  • References