A
A
Alexander Odintsov2016-04-22 00:58:38
Java
Alexander Odintsov, 2016-04-22 00:58:38

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();

doesn't work with any.
Here is this page: https://www.wrike.com/ru/price/
The item I need:
<div class="tariffs-wrap-btn"> 
<a href="#" id="start-free-trial-professional" class="a-8ab62f btn-professional"> Попробовать&nbsp;бесплатно<span class="btn_sm_sprite blue"></span> </a> </div>

Thank you in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeniy _, 2016-04-22
@GeneD88

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 question

Ask a Question

731 491 924 answers to any question