In this conclusion to a three-part article series on acceptance testing with Ruby on Rails, you'll learn how to use the Selenium IDE and how (and why) to record the results of your acceptance tests. This article is excerpted from chapter 11 of the book Practical Rails Projects, written by Eldon Alameda (Apress; ISBN: 1590597818).
Selenium IDE allows you to record your tests directly in the browser. You simply click the record button and perform the actions in your browser. Selenium IDE also allows you to run and debug tests. These features are all made possible by the inclusion of Selenium Core in the extension. On top of this, Selenium IDE provides you with features like autocompleting commands and saving recorded tests as HTML, Ruby, or other any other user-defined format.
The Selenium IDE project is hosted, like Selenium itself, at www.openqa.com. Install Selenium IDE by going to http://www.openqa.org/selenium-ide/ and accessing the Selenium IDE Downloads page, as shown in Figure 11-2.
Figure 11-2.The Selenium IDE Downloads page
Firefox requires that you allow www.openqa.org to install extensions on your machine. So, your first step is to click the Edit Options button at the top left of the Selenium IDE Downloads page (see Figure 11-2) and add www.openqa.org to the list of privileged sites.
Next, click the Download link again. This time, you should see the dialog box shown in Figure 11-3. To continue with the installation, click the Install button.
After restarting Firefox, you can open Selenium IDE by selecting Tools -> Selenium IDE from the browser menu bar. You should now see the Selenium IDE window, as shown in Figure 11-4.
Figure 11-3.Installing the Selenium IDE extension
Figure 11-4.The Selenium IDE window
The Selenium IDE window has two tabs:
The Table tab is where the recorded commands are shown. Right-click a row to see a context-sensitive pop-up menu that allows you to insert new commands, delete existing commands, and perform other actions.
The Source tab is where the actual source for the acceptance test is shown. You can either copy and paste the code or use the File -> Save Test menu item to save the test to a file. You can switch between different supported output formats by selecting the appropriate option from the Options -> Format menu.