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) byId(id, maxTime) → {Promise.<void>}

Waits for an element with a specific ID to appear within a maximum time.
Parameters:
NameTypeDescription
idstringThe ID of the element to wait for.
maxTimenumberMaximum time to wait in milliseconds.
Throws:
Throws an error if the element is not found within the specified time.
Type
Error
Returns:
A promise that resolves when the element is found 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) bySelector(selector, maxTime) → {Promise.<void>}

Waits for an element located by a CSS selector to appear within a maximum time.
Parameters:
NameTypeDescription
selectorstringThe CSS selector of the element to wait for.
maxTimenumberMaximum time to wait in milliseconds.
Throws:
Throws an error if the element is not found within the specified time.
Type
Error
Returns:
A promise that resolves when the element is found or the time times out.
Type: 
Promise.<void>

(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) byXpath(xpath, maxTime) → {Promise.<void>}

Waits for an element located by XPath to appear within a maximum time.
Parameters:
NameTypeDescription
xpathstringThe XPath of the element to wait for.
maxTimenumberMaximum time to wait in milliseconds.
Throws:
Throws an error if the element is not found within the specified time.
Type
Error
Returns:
A promise that resolves when the element is found or the time times out.
Type: 
Promise.<void>