@luminati-io/webdriverio8
Version:
Next-gen browser and mobile automation test framework for Node.js
35 lines • 2.43 kB
JavaScript
/**
* Wait for an element for the provided amount of milliseconds to be clickable or not clickable.
*
* :::info
*
* As opposed to other element commands WebdriverIO will not wait for the element to exist to execute
* this command.
*
* :::
*
* <example>
:waitForClickable.js
it('should detect when element is clickable', async () => {
const elem = await $('#elem')
await elem.waitForClickable({ timeout: 3000 });
});
it('should detect when element is no longer clickable', async () => {
const elem = await $('#elem')
await elem.waitForClickable({ reverse: true });
});
* </example>
*
* @alias element.waitForClickable
* @param {WaitForOptions=} options waitForEnabled options (optional)
* @param {Number=} options.timeout time in ms (default: 500)
* @param {Boolean=} options.reverse if true it waits for the opposite (default: false)
* @param {String=} options.timeoutMsg if exists it overrides the default error message
* @param {Number=} options.interval interval between checks (default: `waitforInterval`)
* @return {Boolean} `true` if element is clickable (or doesn't if flag is set)
*
*/
export async function waitForClickable({ timeout = this.options.waitforTimeout, interval = this.options.waitforInterval, reverse = false, timeoutMsg = `element ("${this.selector}") still ${reverse ? '' : 'not '}clickable after ${timeout}ms` } = {}) {
return this.waitUntil(async () => reverse !== await this.isClickable(), { timeout, timeoutMsg, interval });
}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoid2FpdEZvckNsaWNrYWJsZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9jb21tYW5kcy9lbGVtZW50L3dhaXRGb3JDbGlja2FibGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBRUE7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OztHQThCRztBQUNILE1BQU0sQ0FBQyxLQUFLLFVBQVUsZ0JBQWdCLENBRWxDLEVBQ0ksT0FBTyxHQUFHLElBQUksQ0FBQyxPQUFPLENBQUMsY0FBYyxFQUNyQyxRQUFRLEdBQUcsSUFBSSxDQUFDLE9BQU8sQ0FBQyxlQUFlLEVBQ3ZDLE9BQU8sR0FBRyxLQUFLLEVBQ2YsVUFBVSxHQUFHLGFBQWEsSUFBSSxDQUFDLFFBQVEsWUFBWSxPQUFPLENBQUMsQ0FBQyxDQUFDLEVBQUUsQ0FBQyxDQUFDLENBQUMsTUFBTSxtQkFBbUIsT0FBTyxJQUFJLEtBQ3RGLEVBQUU7SUFFdEIsT0FBTyxJQUFJLENBQUMsU0FBUyxDQUNqQixLQUFLLElBQUksRUFBRSxDQUFDLE9BQU8sS0FBSyxNQUFNLElBQUksQ0FBQyxXQUFXLEVBQUUsRUFDaEQsRUFBRSxPQUFPLEVBQUUsVUFBVSxFQUFFLFFBQVEsRUFBRSxDQUNwQyxDQUFBO0FBQ0wsQ0FBQyJ9