Monday, August 24, 2009

Basics of web test automation using Selenium

What is Selenium?
Selenium is a JavaScript-based framework for recording and running automated tests in a web browser.

Why Selenium?
Use Selenium to automate functional regression tests.

Functional means user-facing tests, not just back-end or code-level tests. Regression tests means tests that can be used to measure the progress of the product against past behavior, to make sure it does not regress (worsen in quality for core features). To put it in other terms, Selenium can help save time and/or improve quality (including predictability).

Two Approaches
There are two general approaches for using Selenium to improve testing:
  1. Manual testing: You can simply run Selenium scripts as part of a manual, or semi-automated, testing process, using just the Selenium IDE (available for Firefox only). If you don't have an automated build, this approach may be a good way to get started testing faster right away.
  2. Automated testing: Selenium test scripts can also be launched programmatically, from a first-class programming language such as Java. They can run in the context of a JUnit test suite, for example as part of a build process. This is the more automated approach. In the long run, it is a good idea to transition tests to become more automated. Another advantage of this approach is it enables using Selenium RC, a remote-control test execution environment that lets you run tests on remote machines in essentially any browser.
Automate Which Tests?
Which tests should you automate with Selenium? The answer is not always obvious. A high-level answer is that you should automate tests that give the biggest bang for the buck. Good reasons to automate a certain test include:
  • The test has identified bugs in the past.
  • The test should be run frequently.
  • The test is boring or difficult to run manually.
  • The test is for a high-priority part of the application under test (AUT).
  • Leaving a bug in this particular area of the application would be costly.
Especially at the beginning of product development or automated test development, automating core feature tests probably makes more sense than very new, unusual, or experimental features.

Download IDE
Selenium IDE is a plugin for Firefox that you use to create and run Selenium tests. It is one of several tools that can work together. It makes sense to start with Selenium IDE because you can record, edit, and run tests using it. Download here:
http://seleniumhq.org/download/

Generally the version at the top is best.

No comments:

Copyright 2011 by William Cain