Image (not element) visibility using WebDriver

I have a clickable image and it does not display in FireFox. I mean, there is no image, but is there an element (and it is clickable). FindElement (by) .Displayed returns true, but there is still no image. The question is, how can I check if this image is visible?

Also, I found an error in the html headers (the reason why the image is not visible), maybe there is a way to check for the presence of the image using the html headers?

public bool IsFileIconDisplayed() { return IsElementDisplayed(By.XPath("//*[@class='SomeClass']/img")); } protected bool IsElementDisplayed(By by) { return FindElement(by).Displayed; } 
+4
source share
2 answers

Does the image create a style that sets its width and height for the given values?

If you cannot request the width and height property of the image elements in Javascript.

 document.getElementById(<webElement>).getClientRects()[0].width document.getElementById(<webElement>).getClientRects()[0].height 

or simply

 document.getElementById(<webElement>).naturalWidth 

With the JavascriptExecutor, you can draw these values โ€‹โ€‹into your Java / C # code and complete the upload / download of the image by its width / height.

+4
source

This thread contains valuable information on how to check image visibility (pay attention to the answer provided by Dave Hunt)

How to check the url for 404 using Selenium WebDriver?

0
source

All Articles