Reputation: 473
I'm brand new to Cucumber and Capybara and I'm having trouble understanding what this one line of code in my homework does. "rating" is a movie rating (G, PG-13, etc.) that is searched for in a table of movies in this context:
assert page.has_xpath?('//td', :text => "#{rating}")
Could someone explain what every part of this line does?
Upvotes: 0
Views: 99
Reputation: 3752
If any element named td
has the contents of the given rating, it succeeds.
Upvotes: 0
Reputation: 12826
It checks whether the page contains an element matching the XPath //td
, that has a text node "#{rating}"
. If it doesn't, it fails the test.
The XPath //td
matches every td
element regardless of its location in the document (because of the double slash).
Here are links to the documentation:
Upvotes: 3