Using capybara + cucumber, let's say your step
Then I should see the following (#MYTABLE) | FOO | 94040 | "friendly" | | BAR | 94050 | "competition"|
step definition
Then /^I should see the following games:$/ do |expected_table| table_results = page.find('#DOM_ID') end
My complex approach to defining
When /^(.*) in the "([^\"]*)" column of the "([^\"]*)" row$/ do | action, column_title, row_title| col_number = 0 all(:xpath, "//*[(th|td)/descendant-or-self::*[contains(text(), '#{column_title}')]]/th").each do |element| col_number += 1 break if element.has_content?(column_title) end within :xpath, "//*[(th|td)/descendant-or-self::*[contains(text(), '#{row_title}')]]/td[#{col_number}]" do When action end end
to check that the table structure is genetic, you can use check the number of rows of X page.should have_selector ('table tr' ,: count => X)
source share