selenium Waiting in Selenium Wait in Java with selenium


Example

Explicit wait : Wait for a certain condition to occur before proceeding further in the code.

WebDriver driver = new FirefoxDriver();
driver.get("http://google.com");
WebElement myElement = (new WebDriverWait(driver, 10))
  .until(ExpectedConditions.presenceOfElementLocated(By.id("myElement")));

Implicit wait: Wait for a certain amount of time when trying to find an element or elements if they are not immediately available.

WebDriver driver = new FirefoxDriver();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.get("http://google.com");
WebElement myElement = driver.findElement(By.id("myElement"));