Wait

Provides functionality to wait for different conditions in the browser.

Classes

Wait

Methods

(async) byCondition(jsExpression, maxTime) → {Promise.<void>}

Waits for a JavaScript condition to return a truthy value within a maximum time.
Parameters:
NameTypeDescription
jsExpressionstringThe JavaScript expression to evaluate.
maxTimenumberMaximum time to wait in milliseconds.
Throws:
Throws an error if the condition is not met within the specified time.
Type
Error
Returns:
A promise that resolves when the condition becomes truthy or the time times out.
Type: 
Promise.<void>

(async) byPageToComplete() → {Promise.<void>}

Waits for the page to finish loading.
Returns:
A promise that resolves when the page complete check has finished.
Type: 
Promise.<void>
Example
async commands.wait.byPageToComplete();

(async) byTime(ms) → {Promise.<void>}

Waits for a specified amount of time.
Parameters:
NameTypeDescription
msnumberThe time in milliseconds to wait.
Returns:
A promise that resolves when the specified time has elapsed.
Type: 
Promise.<void>
Example
async commands.wait.byTime(1000);

(async) run(selector, optionsopt) → {Promise.<void>}

Waits for an element using a unified selector string to appear within a maximum time. Supports CSS selectors (default), and prefix-based strategies: 'id:myId', 'xpath://div', 'name:field', 'class:loaded'.
Parameters:
NameTypeAttributesDescription
selectorstringThe selector string. CSS by default, or use a prefix.
optionsObject<optional>
Options for waiting.
Properties
NameTypeAttributesDefaultDescription
timeoutnumber<optional>
6000Maximum time to wait in milliseconds.
visibleboolean<optional>
falseIf true, waits for the element to be visible, not just present.
Throws:
Throws an error if the element is not found within the timeout.
Type
Error
Returns:
A promise that resolves when the element is found.
Type: 
Promise.<void>