In this second part of a three-part article series on acceptance testing with Ruby on Rails, you will learn the various commands that are performed during this process, and start your first acceptance test. This article is excerpted from chapter 11 of the book Practical Rails Projects, written by Eldon Alameda (Apress; ISBN: 1590597818).
Assertions, or checks, verify that the state of the application is as expected after one or more actions have been executed by Selenium. For example, you can test that the title of the page or the value of a variable is correct.
Assertions are split into three groups that behave somewhat differently:
Assertions (assert) abort the test if they fail.
Verifications (verify) log the error and allow the test to continue.
Wait for (waitFor) assertions wait for the specified event to happen. They can be used for testing Ajax functionality. For example, you can wait for the value of an element on the page to be updated by an Ajax request.
Table 11-2 shows a partial list of supported Selenium assertions.
Table 11-2. Commonly Used Selenium Assertions
Asserts the location of the currently loaded page; for example, that itís /forumand not /catalog
Asserts that the title of the currently loaded page is correct
Asserts that the specified text is present on the page
Verification and wait for assertions use the same format. Use verifyLocation(/forum) to verify that the location is /forum, and use waitForLocation(/forum) to wait for that page to be loaded.