0

I am working on selenium, while running Java code I tried to CLICK a menu from the web page but encounter error of selenium.ElementNotVisibleException: Element is not currently visible Kindly advise on this matters . Thanks you

HTML code for text field :

<li onclick="goin('pages/AbcProxy/proxyGroupList.do')>
 <a href="javascript::">TESTABC</a>

JAVA code:

WebdriverWait wait = new WebDriverWait(driver,50);
wait until(ExpectedConditions.presenceOfElementLocated(By.xpath("/html/body/div/div/ul/li[12]/a")));
Bartłomiej Semańczyk
61.9k52 gold badges255 silver badges406 bronze badges
asked Mar 1, 2016 at 9:57

2 Answers 2

1

presenceOfElementLocated checks if the element exists in the DOM. To check if the element is visible use visibilityOfElementLocated

WebdriverWait wait = new WebDriverWait(driver,50);
WebElement element = wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("/html/body/div/div/ul/li[12]/a")));
element.click();
answered Mar 1, 2016 at 10:13
Sign up to request clarification or add additional context in comments.

2 Comments

Hi , if i use the method of visibilityOfElementLocated does it effect unable to onclick this element ?
@JaydenNg this will return the element it was waiting for. If the element is visible it will get into element in my example. You can use it to send the click.
0

It might be that your xpath is to a different a element that is invisible (css display none or such).

It would be better to use some id first (maybe for the parent ul?) and then a relative xpath from there, full xpaths from root are not recommended as it makes the test very brittle

answered Mar 1, 2016 at 10:10

2 Comments

Hi @the-noob , do you mind show some example , as im stuck on this matters. Thanks you
For that I would need a bit more html, is there an id attribute for any of the parents of a ?

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.