Chapter 3: Handling Waits and Synchronization
By Shivam Singh, founder of TesterRank · Updated September 2026
FluentWait is the configurable version of WebDriverWait. In fact, WebDriverWait is built on top of FluentWait with sensible defaults. You use FluentWait when you need to control three things yourself: the total timeout, how often it checks (polling interval), and which exceptions to ignore while waiting.
Under the hood, WebDriverWait is actually a specialized subclass of FluentWait. FluentWait provides maximum control over the polling engine: configuring the polling frequency (e.g. check every 100ms instead of 500ms), specifying which exceptions to ignore during the wait cycle, and setting descriptive timeout error messages.
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.StaleElementReferenceException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.FluentWait;
import org.openqa.selenium.support.ui.Wait;
import java.time.Duration;
Wait<WebDriver> fluentWait = new FluentWait<>(driver)
.withTimeout(Duration.ofSeconds(20)) // Maximum duration
.pollingEvery(Duration.ofMillis(200)) // Poll frequency (default is 500ms)
.ignoring(NoSuchElementException.class) // Suppress during wait cycle
.ignoring(StaleElementReferenceException.class) // Suppress DOM re-render glitches
.withMessage("Timed out waiting for NetBanking transfer confirmation modal to render");
WebElement confirmationModal = fluentWait.until(d -> {
WebElement modal = d.findElement(By.id("transfer-confirmation-modal"));
return modal.isDisplayed() ? modal : null;
});Polling every 500 ms is fine for most pages. Poll faster (100–200 ms) only for very quick UI changes you need to catch. Poll slower (1–2 seconds) for slow background jobs, like a report that takes 30 seconds to generate, so your test is not hammering the page with checks.
withTimeout — the maximum time to wait.pollingEvery — how often to check the condition.ignoring — exceptions that mean "not ready yet", such as NoSuchElementException or StaleElementReferenceException.withMessage — a clear message shown if the wait times out. Always add one; it makes failures much easier to debug.Key Point: FluentWait gives you full control over polling frequency, ignored exceptions, and custom failure diagnostics. Use it for complex dynamic SPAs.