Answer the question
In order to leave comments, you need to log in
How to fix ElementNotVisibleException in Selenium test?
Hello. There was a need to write a test for the site. I am facing this for the first time. During the test, you need to follow the links one by one, filling in the text fields along the way. Everything works fine, but on one of the pages I can’t access one element, it throws an ElementNotVisibleException. Tried several options:
driver.findElement(By.xpath(".//*[@id='start-free-trial-professional']"));
driver.findElement(By.id("start-free-trial-professional")).click();
driver.findElement(By.linkText(" Попробовать бесплатно")).click();
<div class="tariffs-wrap-btn">
<a href="#" id="start-free-trial-professional" class="a-8ab62f btn-professional"> Попробовать бесплатно<span class="btn_sm_sprite blue"></span> </a> </div>
Answer the question
In order to leave comments, you need to log in
Use ("(//a[@id='start-free-trial-professional'])[2]"), because with your By.id("start-free-trial-professional") selenium tries to click on an invisible element. (This id returns 3 elements, the first of which has display: none)
If you want to get rid of the xpath index, specify a style on the element. What would only return the visible.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question