更新时间:2023-10-28 16:35:34
Nokogiri 的解决方案应该可以正常工作.唯一的问题是 Cabybara API 与 Webrat 不同,因此您必须使用 page.body
而不是 response.body
.
The solution with Nokogiri should work fine. The only problem is that the Cabybara API is different to Webrat, so instead of response.body
, you must use page.body
.
但还有一种更好的方法来使用 Cabybara 测试图像:
But theres an even better way to test for the image with Cabybara :
Then /^I should see the image "(.+)"$/ do |image|
page.should have_xpath("//img[@src="/public/images/#{image}"]")
end