Selenium – ElementNotVisibleException



ElementNotVisibleException – Clicking Hidden Elements

A hidden element is not clickable on web page. There are certain CSS properties you may find on web page which makes the element non-visible as given below:

style = “display: none;”

style = “visibility: hidden;”

style = “height: 0px”

To overcome this issue, you may try JavaScript Executor provided by Selenium WebDriver

WebElement element = driver.findElement(By.xpath(“//div[@class=’container’]/div”));
((JavascriptExecutor) driver).executeScript(“arguement[0].click();”, element);

If this does’nt work, inject the script (which is not a good practice) to make this element visible something like this:

String script = “arguments[0].style.height=’auto’; arguments[0].style.visibility=’visible’;”;

and pass it in JavaScript Executor

((JavascriptExecutor) driver).executeScript(script, element);

then finally,

element.click();

And there you go !! You have clicked an hidden element

Happy Testing !!

Tags:
Leave a comment

Your email address will not be published. Required fields are marked *

Subscribe now

Receive weekly newsletter with educational materials, new courses, most popular posts, popular books and much more!

https://bridgejunks.com/ https://crownmakesense.com/ https://brithaniabookjudges.com/ https://hughesroyality.com/ https://rhythmholic.com/ https://bandar89.simnasfikpunhas.com/ https://www.100calshop.co.il/products/thailand/ https://myasociados.com/ https://solyser.com/ http://konfidence.cz/ https://muscadinepdx.com/ https://bandar89.parajesandinos.com.ve/ https://goremekoop.com/ https://oncoswisscenter.com/ https://www.turunclifehotel.com/bandar89/ https://www.houseofproducts.biz/ https://taimoormphotography.com/
BIJI18 BIJI18 BIJI18