1//required import
2WebDriver driver = new ChromeDriver();
3// Timeout in seconds
4WebDriverWait wait = new WebDriverWait(driver, 15);
5
6//Three most common explicit waits
7
8//waits until the element is visible and can be clicked
9wait.until(ExpectedConditions.elementToBeClickable(By.id("button1")));
10
11//waits until the element is visible on the page somewhere i.e. pixels > 0
12wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("text_box1")));
13
14//waits until the element is removed from the page
15//This one is helpful when moving from one page to another
16wait.until(ExpectedConditions.invisibilityOfElementLocated(By.id("text_box1")));
17
18//implicit wait will wait a set time, similar to Thread.sleep();
19driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
20
21//There is also a FluentWait, but I am unfamiliar with it