My page has a <th> tag that has “attendance” as its CSS class. The following Cucumber step fails:
Then I should see "Name" within "th"
while this one passes:
Then I should see "Name" within "th.attendance"
Do I really have to use this level of specificity? I feel like, for Cucumber, that’s requiring too much knowledge of the underlying code being tested and it should be a bit more generic.
In other words, how would I say “Just find ‘[value]’ within any ‘th’ tag”? And am I wrong for wanting to do so?
Try the following. It finds the given text within the given selector, using xpath.
"//#{selector}"means that it should find tag that matches the selector."[contains(text(),'#{text}']"means that the tag text should contain the given text.