Selenium Webdriver Java How to Wait Until a Link Is Present

Selenium Webdriver Java How to Wait Until a Link Is Present

I have a link that I press and then it runs some JS and a new link is generated on the page which has the text "View report"

How can I wait on the page until this link is present and clickable, or timeout if its not displayed in say five minutes?

I have seen this question asked a few times and tried some of the solutions but can't get any to work.

I've even tried a rubbish way of just waiting for a minute but sometimes the link takes longer to appear so it fails.

1 Answer

Try this WebDriverWait wait = new WebDriverWait(driver, 60);// 1 minute wait.until(ExpectedConditions.visibilityOfElementLocated(By.linkText("View report")));

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

James H. Sterling
Author

James H. Sterling

James Sterling reports on renewable energy developments, climate policy, ecological conservation, and green tech innovations around the globe.