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).
Recording Acceptance Tests - Recording the Show Post Acceptance Test (Page 4 of 5 )
Next, we'll create a test that verifies that the Show Post user story works as intended. You should now have the forum main page open in Firefox, which is where we left off in the previous section.
Like the other tests, the test case requires that we are on the page where the previous test ended. We'll use the assertLocation check to verify this. Record the acceptance test by following these steps:
Select File -> New Test from the Selenium IDE menu. Verify that Selenium IDE is recording, by checking that the red record button is activated.
Click the Source tab and type |assertLocation|/forum|| in the text area, as shown in Figure 11-10. Switch back to the previous view by clicking the Table tab.
Figure 11-10.The Source tab showing the acceptance test after step 2
Click the second line in the table.
Click the post that was created by the Post to Forum acceptance test (The Dice Man). You are now taken to the show post page.
Select the text "The Dice Man," right-click it, and select verifyTextPresent The Dice Man from the pop-up menu.
Select the text "Luke Rhinehart," right-click it, and select verifyTextPresent Luke Rhinehart from the pop-up menu.
Right-click the Reply link and select assertTextLink link=Reply Reply from the pop-up menu.
Save the test as test/selenium/forum/03_show_post.sel (by selecting File -> Save Test from the Selenium IDE menu).