Reputation: 14671
I am doing homework and need to check if HTML table column has given text. I copied example from web_steps.rb and tried to change to fit my need but test fails. Step:
And I should not see 'G'
Step definition that fails:
Then /^(?:|I )should not see '([^']*)'$/ do |text|
save_and_open_page
if page.respond_to? :should
page.find('#movies').should have_no_content(text)
else
assert page.find('#movies').has_no_content?(text)
end
end
Error is:
expected #has_no_content?("G") to return true, got false (RSpec::Expectations::ExpectationNotMetError) ./features/step_definitions/movie_steps.rb:35:in
/^(?:|I )should not see '([^']*)'$/' features/filter_movie_list.feature:37:in
And I should not see 'G''
Table looks like:
I am stuck here and couldn't go further. Can someone give me some hint to solve this problem?
Upvotes: 4
Views: 1113
Reputation: 5426
You can try with:
assert page.find('#movies').has_no_content?(">#{text}<")
Upvotes: 4
Reputation: 11647
Well the reason it fails is because it sees the capital G in "PG". Basically, what you want is to see no TD cell under the "Rating" column having a G rating, right? What you might want to try using is XPath in your step to drill down in to the TD's and check that the whole cell does/does not contain your text.
Upvotes: 1