samedi 11 juillet 2020

Selenium webdriver: How to check an img element really have height attribute

in java Selenium web driver on chrome, I need to make sure that an image has a height attribute. The HTML code I have is this:

<img src="https://www.w3schools.com/tags/img_girl.jpg">

and I'm trying to execute

 boolean s = driver.findElement(By.tagName("img")).getAttribute("height") !=null;

but this always returns true although there's no height attribute! and if I try to execute

String s = driver.findElement(By.tagName("img")).getAttribute("height");

I'll get 600 despite there is no height attribute in the HTML code. is there any other way I can check it?

Aucun commentaire:

Enregistrer un commentaire