0

I am using Webdriver and trying to click on a link (Billing) which further has a dropdown(My Quotes). To locate billing and then to click on My Quotes link, I am using the below code:

String xp = "//*[@id='Primary_Navbar-Billing']/a";  // With this xpath I can search on my Firefox browser but using the same in my code gives me an error: 

WebElement menu = driver.findElement(By.xpath(xp));


    driver.manage().timeouts().implicitlyWait(50, TimeUnit.SECONDS);
    // Initiate mouse action using Actions class
    Actions builder = new Actions(driver);    

    // move the mouse to the earlier identified menu option
    builder.moveToElement(menu).build().perform();

    //identify menu option from the resulting menu display and click
    driver.findElement(By.linkText("My Quotes")).click();

I am getting an error:

Exception in thread "main" org.openqa.selenium.ElementNotVisibleException:

1

1 Answer 1

1

you can try those 3 options:

  • Add a Thread.sleep(YourMilliSecondesTime); before your click(); action.

  • Use Xpath instead By.linkText to find your link, Xpath is ALWAYS the better option.

  • or try this: driver.findElement(By.xpath("//span[text()='YOURLINKTEXTEHERE']")).click()); if for any reason you don't have a good xpath for this element.

Hope this will help. :)

Sign up to request clarification or add additional context in comments.

1 Comment

or explicity wait or use Id. Many Options.

Your Answer

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.