Selenium - check if an image is displayed on page

后端 未结 5 1355
天涯浪人
天涯浪人 2020-12-12 23:25

I\'m creating a suite of Selenium tests for an web album application. I would like to test whether an image is actually displayed (it contains valid image data). Is such thi

5条回答
  •  醉梦人生
    2020-12-12 23:47

    If you are willing to use the TestPlan frontend to Selenium there a few options. Once you have the URL of the image you can grab this URL and inspect the returned headers. you can also save the data to a file if you'd like to manually inspect it. Or you can write a validator in Java to take that data and check to see if it actually decodes.

    If you're willing to try it out then I'll write you a sample script. I can even do a quick image validator function if you'd like.

提交回复
热议问题