@qavajs/steps-wdio
Version:
qavajs steps to interact with webdriverio
85 lines • 4.77 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@qavajs/core");
/**
* Explicit wait
* @param {number} ms - milliseconds
* @example I wait 1000 ms
*/
(0, core_1.When)('I wait {int} ms', async function (ms) {
await this.wdio.browser.pause(ms);
});
/**
* Refresh page unless element matches condition
* @param {string} alias - element to wait condition
* @param {string} wait - wait condition
* @param {number|null} [timeout] - custom timeout in ms
* @example I refresh page until 'Internal Server Error Box' to be visible
* @example I refresh page until 'Submit Button' to be enabled
* @example I refresh page until 'Place Order Button' to be clickable (timeout: 3000)
*/
(0, core_1.When)('I refresh page until {wdioLocator} {wdioCondition}( ){wdioTimeout}', async function (element, condition, timeoutValue) {
const timeout = timeoutValue !== null && timeoutValue !== void 0 ? timeoutValue : this.config.browser.timeout.value;
await this.wdio.browser.waitUntil(async () => {
await this.wdio.browser.refresh();
await condition(element(), this.config.browser.timeout.pageRefreshInterval);
return true;
}, { timeout, interval: this.config.browser.timeout.pageRefreshInterval });
});
/**
* Refresh page unless element text matches condition
* @param {string} alias - element to wait condition
* @param {string} wait - wait condition
* @param {string} value - expected value to wait
* @param {number|null} [timeout] - custom timeout in ms
* @example I refresh page until text of 'Order Status' to be equal 'Processing'
* @example I refresh page until text of 'Currency' not contain '$'
* @example I refresh page until text of 'My Salary' to match '/5\d{3,}/' (timeout: 3000)
*/
(0, core_1.When)('I refresh page until text of {wdioLocator} {validation} {value}( ){wdioTimeout}', async function (element, validation, expected, timeoutValue) {
const timeout = timeoutValue !== null && timeoutValue !== void 0 ? timeoutValue : this.config.browser.timeout.value;
await this.wdio.browser.waitUntil(async () => {
await this.wdio.browser.refresh();
const value = () => element().getText();
await validation.poll(value, await expected.value(), {
timeout: this.config.browser.timeout.pageRefreshInterval,
interval: this.config.browser.timeout.valueInterval
});
return true;
}, { timeout, interval: this.config.browser.timeout.pageRefreshInterval });
});
/**
* Repeatedly click an element unless element text matches condition
* @param {string} aliasToClick - element to wait condition
* @param {string} aliasToCheck - element to wait condition
* @param {string} wait - wait condition
* @param {string} text - expected value to wait
* @param {number|null} [timeout] - custom timeout in ms
* @example I click 'Send Message Button' until text of 'Information Alert' to be equal 'Your account has been banned'
* @example I click 'Add To Cart Button' until text of 'Shopping Cart Total' to match '/\$5\d{3,}/' (timeout: 3000)
*/
(0, core_1.When)('I click {wdioLocator} until text of {wdioLocator} {validation} {value}( ){wdioTimeout}', async function (elementToClick, elementToCheck, validation, expected, timeoutValue) {
const timeout = timeoutValue !== null && timeoutValue !== void 0 ? timeoutValue : this.config.browser.timeout.value;
await validation.poll(async () => {
await elementToClick().click();
return elementToCheck().getText();
}, await expected.value(), { timeout, interval: this.config.browser.timeout.actionInterval });
});
/**
* Repeatedly click an element unless element value attribute matches condition
* @param {string} aliasToClick - element to wait condition
* @param {string} aliasToCheck - element to wait condition
* @param {string} wait - wait condition
* @param {string} value - expected value to wait
* @param {number|null} [timeout] - custom timeout in ms
* @example I click 'Plus Button' until value of 'Quantity Input' to be equal '9'
* @example I click 'Suggest Button' until value of 'Repository Name Input' to match '/\w{5,}/' (timeout: 30000)
*/
(0, core_1.When)('I click {wdioLocator} until value of {wdioLocator} {validation} {value}( ){wdioTimeout}', async function (elementToClick, elementToCheck, validation, expected, timeoutValue) {
const timeout = timeoutValue !== null && timeoutValue !== void 0 ? timeoutValue : this.config.browser.timeout.value;
await validation.poll(async () => {
await elementToClick().click();
return elementToCheck().getValue();
}, await expected.value(), { timeout, interval: this.config.browser.timeout.actionInterval });
});
//# sourceMappingURL=waits.js.map
;