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
