Passer au contenu principal

waitForEnabled

Wait for an element (selected by css selector) for the provided amount of milliseconds to be (dis/en)abled. If multiple elements get queried by given selector, it returns true if at least one element is (dis/en)abled.

information

As opposed to other element commands WebdriverIO will not wait for the element to exist to execute this command.

Usage
$(selector).waitForEnabled({ timeout, reverse, timeoutMsg, interval })
Parameters
NameTypeDetails
options
optional
WaitForOptionswaitForEnabled options (optional)
options.timeout
optional
Numbertime in ms (default: 500)
options.reverse
optional
Booleanif true it waits for the opposite (default: false)
options.timeoutMsg
optional
Stringif exists it overrides the default error message
options.interval
optional
Numberinterval between checks (default: waitforInterval)
Examples
index.html
<input type="text" id="username" value="foobar" disabled="disabled"></input>
<script type="text/javascript">
setTimeout(() => {
document.getElementById('username').disabled = false
}, 2000);
</script>
waitForEnabledExample.js
it('should detect when element is enabled', async () => {
await $('#username').waitForEnabled({ timeout: 3000 });
});

it('should detect when element is disabled', async () => {
elem = await $('#username');
await elem.waitForEnabled({ reverse: true })
});

Welcome! How can I help?

WebdriverIO AI Copilot