Alex Rivera | Logout

Cucumber/Capybara: check that a page does NOT have content?

Asked 2012-08-16T02:54:56.867
23

Using Cucumber and Capybara, is there a way to verify that a string is NOT present on a page?

For example, how would I write the opposite of this step:

Then /^I should see "(.*?)"$/ do |arg1|
  page.should have_content(arg1)
end

This passes if arg1 is present.

How would I write a step that fails if arg1 is found?

Edit
Report

1 Answer

-4

Oh, wait, I figured it out. This works:

Then /^I should see "(.*?)"$/ do |arg1|
  page.has_content?(arg1) == false
end
answered 2012-08-16T02:59:25.013

Your Answer