Using rspec to verify an xpath (via capybara/cucumber)

I am doing:

page.should have_xpath("//img[contains(@class, ‘foobar’)]", :count =>

but cucumber tells me:

expected xpath “//img[contains(@class, ‘foobar’)]” to return something

… Shouldn’t this be returning true/false ?

Patrick J. Collins

On Sep 20, 2011, at 11:45 PM, Patrick J. Collins wrote:

… Shouldn’t this be returning true/false ?
have_xpath is a Capybara matcher that defines its own failure message:


“have_[xpath]” is a custom matcher in Capybara. So, the answer would be

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs