wdio-wait-for
Version:
a library of conditions that are useful for end-to-end tests
24 lines (23 loc) • 566 B
JavaScript
/**
* A condition for checking an alert on the page
*
* @example
* browser.waitUntil(alertIsPresent());
*
* @returns {!function} A condition that returns a promise
* representing whether an alert is present.
*/
export function alertIsPresent() {
return async function () {
try {
await this.getAlertText();
return true;
}
catch (err) {
if (err instanceof Error && err.message.includes('no such alert')) {
return false;
}
throw err;
}
};
}