liveBook · Manning

Wait

As explained in BDD in Action, Second Edition

Wait is a Serenity BDD waiting utility that pauses execution until an arbitrary function has completed or a supplied condition is met.

Wait coordinates test execution with an asynchronous application. Instead of checking immediately after an action, it pauses until a condition becomes true or a timeout expires. This prevents tests from failing simply because a notification, search result, API response, or backend update has not appeared yet. section 10.2.15 section 12.5.3

Choose a condition that represents the state the test actually needs:

Waiting for flight-search results

A search displays a spinner while results load. A Page Object can click Search and wait for the spinner to become invisible, leaving the step definition focused on the business action rather than browser timing details. In Screenplay, the equivalent is to wait until the flight container is visible or the spinner is not visible. section 11.3.6 section 12.5.3

tracy.attemptsTo(
        Wait.until(() -> fileIsProcessed()).           #1
            .forNoMoreThan(Duration.of(3, SECONDS))    #2
    );

Shows a Serenity BDD Wait interaction that waits for an arbitrary function, such as file processing, for no more than a specified duration. section 12.5.3

How BDD in Action, Second Edition covers it

How deep it goes
Explains predefined, fluent, and arbitrary-function waits with timeouts, polling, and encapsulation, but defers broader synchronization internals.
Examples
Uses transient login notifications, flight-search spinners, visible results, page titles, and file-processing functions.
What it assumes
Assumes familiarity with automated UI tests and locators while demonstrating wait conditions from basic visibility checks through custom functions.
What you can do after
Apply it via Serenity BDD, Selenium WebDriver, Page Objects, or Screenplay interactions to make asynchronous tests more reliable.
How it connects
Connects wait conditions with Selenium WebDriver, Screenplay Pattern, Page Objects, asynchronous testing, and acceptance criteria.

Also explained in

Compare how 2 books explain wait →

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.