@nice-digital/wdio-cucumber-steps
Version:
Shared step definitions for Cucumber JS BDD tests in WebdriverIO
32 lines • 1.33 kB
JavaScript
;
/*! https://github.com/webdriverio/cucumber-boilerplate/blob/master/src/support/action/waitFor.js */
Object.defineProperty(exports, "__esModule", { value: true });
exports.waitFor = void 0;
/**
* Wait for the given element to be enabled, enabled or exist
* @param {String} selector Element selector
* @param {String} ms Wait duration (optional)
* @param {String} falseState Check for opposite state
* @param {String} state State to check for (default
* existence)
*/
async function waitFor(selector, ms, falseState, state) {
// max number of milliseconds to wait, default 3000
const timeout = parseInt(ms, 10) || 3000;
//Command to perform on the browser object
let command = "waitForExist";
command =
state === "enabled"
? "waitForEnabled"
: state === "displayed"
? "waitForDisplayed"
: "waitForExist";
let reverse = !!falseState;
if (typeof falseState === "undefined") {
reverse = false;
}
const element = await $(selector);
await element[command]({ timeout, reverse });
}
exports.waitFor = waitFor;
//# sourceMappingURL=waitFor.js.map