Wait for page load in Selenium (Java)

Wait for page load in Selenium (Java)

To wait until the page is loaded, the easiest way is to use a WebDriverWait to force the driver to wait until an element is visible that you know is only present on the page you are navigating to.You can do this using WebDriverWait, a class that is used in conjunction with ExpectedConditions to wait for a certain condition to be met.

WebDriverWait wait = new WebDriverWait(driver, 20);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("searchInput")));

Leave a reply

Your email address will not be published. Required fields are marked*

CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.