Reduce the explicit waits duplicated code with a custom driver class

Alex Siminiuc
3 min readJul 12, 2022

Any Selenium test automation code should synchronize with the page by waiting for an element to be present with a specific state (enabled, visible, hidden) before the element is used.

This is done with explicit waits and expected conditions (not with implicit waits) as follows:

WebDriverWait wait = new WebDriverWait(driver, 30);wait.until(ExpectedConditions.visibilityOfElementLocated(loc));
WebElement element = driver.findElement(loc);

--

--