I need to check that some content exists on the page within a specific type of selector. For example, let's say I have the following HTML:
<h2>HEADLINE ONE</h2>
<h2>HEADLINE TWO</h2>
I know how to select only the first one on the page:
find('h2').should have_content('Headline Two') # have_content is also case insensitive
How would I check that the content exists among all of the h2
s on the page?
Apparently you can select elements with a given text:
page.should have_selector('h2', text: /#{headline}/i)
Note: I used a regular expression to make the text search case insensitive.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With