Say I have a "log in" button in my app, which can be enabled / disabled by the admins. What's the best way to test that this button is not rendered when the log in function is disabled? (The page should render fine, but the button should not be there.)
I can't seem to find a way to expect
the find
to fail. Am I approaching this wrong?
Well, if your button has a class
or an id
then you can check if the page does not include that class
or id
:
expect(page).not_to have_selector "#botton_id" or ".button_class"
or if the name of your button is unique you could check if that doesn't appear on the page:
expect(page).not_to have_content('Button Name')
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