Skip to main content

waitForEnabled

Overview

Use the waitForEnabled command to wait until an element becomes enabled or disabled within a specified number of milliseconds.

warning

Unlike other element commands, Testplane will not wait for the element to exist before executing this command.

Usage

await browser.$(selector).waitForEnabled({ timeout, reverse, timeoutMsg, interval });

Command Parameters

NameTypeDefaultDescription
timeoutNumber500Timeout in milliseconds.
reverseBooleanfalseIf true, the command will wait for the opposite condition: the element becomes disabled.
timeoutMsgStringN/AError message to throw when the timeout is reached.
intervalNumberwaitforIntervalInterval in milliseconds between condition checks.

Usage Examples

index.html

<div id="elem" style="visibility: hidden;">Hello World!</div>
<script type="text/javascript">
setTimeout(() => {
document.getElementById("elem").style.visibility = "visible";
}, 2000);
</script>

waitForEnabled.js

it("should detect when element is visible", async ({ browser }) => {
const elem = await browser.$("#elem");
await elem.waitForDisplayed({ timeout: 3000 });
});

it("should detect when element is no longer visible", async ({ browser }) => {
const elem = await browser.$("#elem");
await elem.waitForDisplayed({ reverse: true });
});

References

We'd like to give credit to the original WebdriverIO docs article, from which we drew some information while writing our version.