How do I find an image on a page with Cucumber / Capybara in Rails 3

前端 未结 8 643
后悔当初
后悔当初 2020-12-24 02:19

I am using Cucumber / Capybara with Rails 3 and am trying to validate the existence of an image after upload. I\'m not sure how to check the url of the image to validate it.

相关标签:
8条回答
  • 2020-12-24 03:15

    Does this work?

    page.should have_xpath('//img[@src="/public/images/foo.png"]')
    
    0 讨论(0)
  • 2020-12-24 03:15

    If you have a lot of images that you would like to test you could create a has_image? matcher for Capybara.

    It is easy and this post explains it step-by-step: Adding a has_image? Matcher to Capybara

    0 讨论(0)
提交回复
热议问题