-
Notifications
You must be signed in to change notification settings - Fork 4
Tables
bfaloona edited this page Sep 13, 2010
·
5 revisions
WatirCraft offers specialized table definitions that make verifing and
accessing tables much easier.
To define table on a page, you must first add an element to wrap the entire table,
then the table and its fields:
element(:items_table) {browser.table(:index, 1)} table(:items) do field(:quantity) {row.cell(:index, 1)} field(:description) {row.cell(:index, 2)} end field(:total) {browser.cell(:id, 'totalcell')}
You can then test specific rows in the table:
some_page.items.row(:description => 'Pragmatic Testing').quantity.should == "3"
There are several things going on here:
- The row method of the “items” table allows you to select a specific row of
the table by reference to any of the fields defined on the table. - You can use any of the defined fields on the selected row.
Additional points:
- If no row matchs the selector, the row method will return nil.
- You can define input fields, just like with pages. This is useful, e.g.,
if there are checkboxes in the table. - You can define elements, just like with pages. This is usefule, e.g.,
if there are buttons in the table. - Index values are 1 based