liveBook · Manning

FluentWait

As explained in BDD in Action, Second Edition

A fluent wait is a configurable synchronization technique that repeatedly checks a condition at specified intervals while handling selected waiting behavior.

FluentWait synchronizes a Selenium test with an asynchronous page by repeatedly evaluating a condition until it succeeds or the timeout expires. It lets the test define a maximum wait, polling interval, and selected exceptions to ignore. section 10.2.15

Waiting for a success notification

A login test can poll for a success toast, ignore NoSuchElementException while it is absent, and continue when its text contains an expected email domain. This handles a notification that fades in after login rather than checking too early. section 10.2.15

Wait<WebDriver> wait = new FluentWait<>(driver)
    .withTimeout(Duration.ofSeconds(30))            #1
    .pollingEvery(Duration.ofSeconds(1))            #2
    .ignoring(NoSuchElementException.class);        #3

The configuration shows a 30-second timeout, one-second polling interval, and ignored missing-element exceptions. section 10.2.15

Use FluentWait when a predefined condition is not specific enough; the condition can locate an element and inspect its text before allowing the test to proceed. section 10.2.15

How BDD in Action, Second Edition covers it

How deep it goes
Configures timeout, polling interval, ignored exceptions, and a custom condition, while stopping short of broader wait-condition coverage.
Examples
Uses a fading Toastr success message and checks that its text contains an expected traveler email domain.
What it assumes
Assumes Java and Selenium WebDriver knowledge, while demonstrating asynchronous-page synchronization through a concrete login scenario.
What you can do after
Apply it via Selenium WebDriver to wait for application state and evaluate custom conditions before continuing a test.
How it connects
Links Selenium WebDriver with asynchronous applications, explicit waits, expected conditions, and UI acceptance testing.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of BDD in Action, Second Edition. The section links point to the parts of the book it draws on.