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.
Usage
$(selector).waitForEnabled(ms, reverse, error)
Parameters
Name | Type | Details |
---|---|---|
ms optional | Number , undefined | time in ms (default: 500) |
reverse optional | Boolean , undefined | if true it waits for the opposite (default: false) |
error optional | String , undefined | if exists it overrides the default error message |
Examples
<input type="text" id="username" value="foobar" disabled="disabled"></input>
<script type="text/javascript">
setTimeout(() => {
document.getElementById('username').disabled = false
}, 2000);
</script>
it('should detect when element is enabled', () => {
$('#username').waitForEnabled(3000);
});
it('should detect when element is disabled', () => {
elem = $('#username');
elem.waitForEnabled(3000, true)
});