# 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.

info

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

## Usage[​](#usage "Direct link to Usage")

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

## Parameters[​](#parameters "Direct link to Parameters")

| Name                                 | Type             | Details                                                                                                  |
| ------------------------------------ | ---------------- | -------------------------------------------------------------------------------------------------------- |
| `options`<br />*optional*            | `WaitForOptions` | waitForEnabled options (optional)                                                                        |
| `options.timeout`<br />*optional*    | `Number`         | time in ms (default set based on [`waitforTimeout`](/docs/configuration.md#waitfortimeout) config value) |
| `options.reverse`<br />*optional*    | `Boolean`        | if true it waits for the opposite (default: false)                                                       |
| `options.timeoutMsg`<br />*optional* | `String`         | if exists it overrides the default error message                                                         |
| `options.interval`<br />*optional*   | `Number`         | interval between checks (default: `waitforInterval`)                                                     |

## Examples[​](#examples "Direct link to 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 })
});
```

## Returns[​](#returns "Direct link to Returns")

* **\<Boolean>** **`return`:** true if element is (dis/en)abled
