Trying to make this test to fail without success.
I’ve got this HTML:
<div id="navigation">
<ul>
<li>
<a href="/url">TV</a>
And then I was trying to identify the text of the A element and make it fail for now.
I’ve used all the following expressions with Xpath but all of them keep passing even though I’m using a different text for the comparison :S
page.should have_xpath("//div[@id='navigation']//a", :content => 'Radio')
page.should have_xpath("//div[@id='navigation']//a", :text => 'Radio')
page.should have_xpath("//div[@id='navigation']//a[contains(string(),'Radio')]")
page.should have_xpath("//div[@id='navigation']//a[contains(text(),'Radio')]")
page.should have_xpath("//div[@id='navigation']//a[contains(.,'Radio')]")
Any idea how I could identify the text of an specific HTML element with capybara?
and… is it possible to achieve the same with CSS?
Cheers!
It turns out that there was another element with the text ‘Radio’ in the ‘navigation’ DIV, so that was causing the test to fail.
For future reference, identifying the 1st element explicitly behaved as expected and fails the test: