If you've built a complicated application and you want to make sure it works, you perform acceptance testing. This three-part article series will show you how to automate the process. It is excerpted from chapter 11 of the book Practical Rails Projects, written by Eldon Alameda (Apress; ISBN: 1590597818).
We'll take a quick look at the Selenium commands and various formats that you can write tests in. After this we'll write an acceptance test for the View Forum user story.
Selenium Commands
Selenium tests have the following basic structure:
|command|target|value|
The items work as follows:
command tells Selenium what to do. For example, you may want to access a page, click a link, and verify that the title of the page is correct. These commands can be classified into the three groups: actions, assertions, and accessors, as described in the following sections.
target tells Selenium on which element to perform the action; for example, you can specify a link or button. The target of an action can be specified with an element locator, which we'll explain after describing the command types.
value is a parameter to the command that tells Selenium, for example, what it should type in a text field.