Explicit wait time

Implicit timeout is generic to all the WebElements of a web page. But, if you have one specific WebElement in your application, where you want to wait for a very long time, this approach may not work. Setting the implicit wait time to the value of this very long time period will delay your entire test suite execution. So, you have to make an exception for only a particular case, such as this WebElement. To handle such scenarios, WebDriver has an explicit wait time for a WebElement.

So, let's see how you can wait for a particular WebElement using WebDriver, with the following code:

WebElement searchBox = (new WebDriverWait(driver, 20))        .until((ExpectedCondition<WebElement>) d -> d.findElement(By.name("q")));

The highlighted ...

Get Selenium WebDriver 3 Practical Guide - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.