Wait
Index
Properties
Methods
Constructors
Properties
staticreadonlyminimumTimeout
Minimum timeout that can be used with Wait.until, defaults to 250 milliseconds,
staticreadonlydefaultPollingInterval
The amount of time Wait.until should wait between condition checks, defaults to 500ms.
Use WaitUntil.pollingEvery to override it for a given interaction.
staticreadonlyminimumPollingInterval
Minimum polling interval of 50ms between condition checks, used with Wait.until.
Methods
staticfor
Instantiates a version of this Interaction configured to wait for a set duration.
Parameters
duration: Answerable<Duration>
A set duration the Actor should wait for before proceeding.
Returns Interaction
staticupTo
Instantiates a version of this Interaction configured to wait until the answer to the question
actual
meets theexpectation
, or thetimeout
expires.Parameters
timeout: Duration
Custom timeout to override SerenityConfig.interactionTimeout
Returns { until: <Actual>(actual: Answerable<Actual>, expectation: Expectation<Actual>) => WaitUntil<Actual> }
until: <Actual>(actual: Answerable<Actual>, expectation: Expectation<Actual>) => WaitUntil<Actual>
Type parameters
- Actual
Parameters
actual: Answerable<Actual>
expectation: Expectation<Actual>
Returns WaitUntil<Actual>
staticuntil
Instantiates a version of this Interaction configured to poll every Wait.defaultPollingInterval for the result of the provided question (
actual
) until it meets theexpectation
, or the timeout expires.Type parameters
- Actual
Parameters
actual: Answerable<Actual>
An Answerable that the Actor will keep answering until the answer meets the Expectation provided, or the timeout expires.
expectation: Expectation<Actual>
An Expectation to be met before proceeding
Returns WaitUntil<Actual>
Constructors
constructor
Returns Wait
Wait
is a synchronisation statement that instructs the actor to wait before proceeding with their next activity, either for a set duration, or until a given expectation is met.You can configure the timeout of the interaction to Wait.until:
Serenity/JS implements
Wait
from scratch, so that the behaviour is consistent no matter the integration tool you use (Playwright, WebdriverIO, Selenium, etc.) or the type of testing you do (Web, REST API, component testing, etc.)Wait with Web-based tests
Example widget
Lean Page Object describing the widget
Waiting for a set duration
Please note that while the above implementation works, this approach is inefficient because at best the actor might wait too long and at worst the test might become “flaky” if any external interference (like network glitches, animations taking a bit too long etc.) makes the actor wait not long enough.
Waiting until a condition is met
Wait.until
makes the Actor keep asking the Question, in this caseText.of(App.status)
, until the answer meets the expectation, or a timeout expires (default: 5s).Please note that both Ensure and Wait can be used with the same expectations, like
equals
orincludes
.Changing the default timeout
Learn more