liveBook · Manning

WaitUntil

As explained in BDD in Action, Second Edition

WaitUntil is a Serenity BDD Screenplay interaction that pauses execution until a specified condition is satisfied.

WaitUntil is a Screenplay interaction that pauses execution until a specified condition is satisfied. It synchronizes tests with asynchronous behavior such as search results arriving, backend state changing, or messages appearing. section 12.5.3

Use a condition that represents the state the scenario actually needs:

  • Wait for an element to become visible, present, enabled, or to contain specified text. section 12.5.3
  • Wait for an element to disappear when a loading spinner or temporary message has finished. section 12.5.3
  • Apply a maximum duration, or wait for a broader condition such as a title, Selenium expected condition, or arbitrary function. section 12.5.3

Waiting for flight results

After a flight search, wait until the loading spinner is no longer visible or the flight container becomes visible. Both approaches express the desired application state rather than relying on a fixed delay.

In Serenity/JS, Wait.until can synchronize a verification task with a temporary toaster message: wait for the message, verify its text, dismiss it, and wait for it to disappear. Encapsulating this sequence in a business-domain task keeps step definitions readable and reusable. section 15.1.7

How BDD in Action, Second Edition covers it

How deep it goes
Explains condition types, maximum durations, expected conditions, arbitrary functions, and business-level task composition.
Examples
Demonstrates flight-result loading, spinner disappearance, visible containers, and temporary toaster-message verification.
What it assumes
Assumes familiarity with Screenplay interactions, application states, element selectors, and basic assertions.
What you can do after
Apply it via Serenity BDD or Serenity/JS to synchronize interactions and compose reusable business-domain verification tasks.
How it connects
Connects Screenplay Pattern, WebElementStateMatchers, Selenium ExpectedConditions, page elements, assertions, and verification tasks.

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.