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).
Commands for Acceptance Testing - Element Locators (Page 3 of 4 )
Element locators tell Selenium which HTML element a command should be performed against. For example, you can tell Selenium to locate a link where the id attribute equals xyz. Some of the element locators that Selenium supports are listed in Table 11-4.
Table 11-4. Some Selenium Element Locators
Finds the element with the specified id attribute
Finds the element with the specified name attribute
Finds the element that has a matching id attribute; if no match is found, finds the element whose name attribute matches the specified id
Finds the element based on an XPath expression; for example, //a[@href='http://google.com']
Finds the link that matches the specified pattern
Selenium Test Formats
Selenium acceptance tests can be written in various ways. The default is HTML format. Selenium on Rails also offers the Selenese and RSelenese formats.
Tests using this format are written as normal HTML documents that contain a table: