How to assert on number of html table rows in ruby using capybara + cucumber How to assert on number of html table rows in ruby using capybara + cucumber ruby ruby

How to assert on number of html table rows in ruby using capybara + cucumber


Even though have_css? will do the trick, your tests should tell you how they failed, rather than just saying some condition was supposed to be true and it was false. With this in mind, the first example below reads much better than the second:

# IF FAILED => "expected 10, got 7"page.all('table#myTable tr').count.should == 10# IF FAILED => "expected true, got false"page.should have_css("table#myTable tr", :count=>10)


I think you can do this:

page.should have_css("table#mytable tr", :count=>3)


For some reason "has_css" does not work for me, however "all(selector)" works really wel

all("table#movies tr").count