Check image is displayed with selenium
You want to check if image is displayed with selenium but selenium API doesn’t really gives you any helpers to do that , so we can implement a small helper to check image is displayed with selenium.
We can actually check if the service returns the proper mime types in the Content-Type HTTP header. Here you can find a list with mime types.
To check the Content-Type header for
image in ruby using Net::HTTP, you should use the following code:
This piece of code will return true of false if the content type it’s an image so you can check it using mini test assertions :
There are also alternatives using xpath to check :