如何验证图片是否正确显示在页面上
How to verify that the image is displayed correctly on the page
我需要验证上传的图片是否正确显示,即它在页面上没有失真。有没有办法验证这一点。?我知道我可以通过内容或屏幕截图进行验证,但这需要手动检查。
提前致谢!
严格来说,不截图是不能确定页面上显示的是你想要的图片。这就是 needle
package 有用的地方。
但是,如果您想避免这种情况,您至少可以验证两件事:
- 有一个
img
元素具有适当的 src
和其他所需属性
它有一个定义,超过0个naturalWidth
value,见:
- Selenium - check if an image is displayed on page
我需要验证上传的图片是否正确显示,即它在页面上没有失真。有没有办法验证这一点。?我知道我可以通过内容或屏幕截图进行验证,但这需要手动检查。
提前致谢!
严格来说,不截图是不能确定页面上显示的是你想要的图片。这就是 needle
package 有用的地方。
但是,如果您想避免这种情况,您至少可以验证两件事:
- 有一个
img
元素具有适当的src
和其他所需属性 它有一个定义,超过0个
naturalWidth
value,见:- Selenium - check if an image is displayed on page