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

前端 未结 8 722
后悔当初
后悔当初 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:10

    Hi I'm not good with XPATH but with CSS you can try :

      if page.respond_to? :should
        page.should have_selector("img[src$='#{imagename}']")
      else
        assert page.has_selector?("img[src$='#{imagename}']")
      end
    

    wish helps ! jramby

提交回复
热议问题