如何测试 cucumber 中的 404 错误(找不到页面)?例如,我有一个包含 100 张图片的页面,我想测试是否所有图片都可见。我想检查一张或多张图片是否有 404 错误。

最佳答案

你可以这样做:

require 'watir-webdriver'
b = Watir::Browser.new
b.goto "apod.nasa.gov/"
b.execute_script("return (typeof arguments[0].naturalWidth!=\"undefined\" && arguments[0].naturalWidth>0)", b.image(name: 'imagename1'))

有关更多信息,请参阅 this blog post

关于cucumber - 如何使用 cucumber 中的 watir-webdriver 测试 404 错误?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/14830721/

10-11 22:03
查看更多