At the core of explicit waits is the incredibly powerful fluent wait API. All the
WebDriverWait objects extend
FluentWait. So, why would we want to use
Well, we get more granular control over the
Wait object, and we can easily specify specific exceptions to ignore. Let's have a look at an example:
Wait<WebDriver> wait = new FluentWait<WebDriver>(driver) .withTimeout(15, TimeUnit.SECONDS) .pollingEvery(500, TimeUnit.MILLISECONDS) .ignoring(NoSuchElementException.class) .withMessage("The message you will see in if a TimeoutException is thrown");
As you can see in the preceding code, we created a wait object with a 15-second timeout that polls every five hundred milliseconds to check whether a condition ...