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
Name | Type | Default | Description |
timeout | Number | 500 | Timeout in milliseconds. |
reverse | Boolean | false | If true, the command will wait for the opposite condition: the element becomes disabled. |
timeoutMsg | String | N/A | Error message to throw when the timeout is reached. |
interval | Number | waitforInterval | Interval 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.