I would like to use page.should have_no_content to check if the page doesn't display the label to user, here what it is in HTML:
<li id="account_input" style="display: none;">
<label for="account_name">My Account</label>
...
</li>
So when I use page.should have_no_content("My Account"), it returns false instead of true.
You could use this statement
find('#account_input').should_not be_visible
I found a solution using:
Then /^"([^\"]+)" should not be visible$/ do |text|
paths = [
"//*[@class='hidden']/*[contains(.,'#{text}')]",
"//*[@class='invisible']/*[contains(.,'#{text}')]",
"//*[@style='display: none;']/*[contains(.,'#{text}')]"
]
xpath = paths.join '|'
page.should have_xpath(xpath)
end
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