waitForEnabled
Ожидание, пока элемент (выбранный с помощью css-селектора) будет (де)активирован в течение указанного количества миллисекунд. Если по заданному селектору выбираются несколько элементов, возвращает true, если хотя бы один элемент (де)активирован.
информация
В отличие от других команд для элементов, WebdriverIO не будет ожидать существования элемента для выполнения этой команды.
Usage
$(selector).waitForEnabled({ timeout, reverse, timeoutMsg, interval })
Parameters
Name | Type | Details |
---|---|---|
options optional | WaitForOptions | waitForEnabled options (optional) |
options.timeout optional | Number | time in ms (default set based on waitforTimeout config value) |
options.reverse optional | Boolean | if true it waits for the opposite (default: false) |
options.timeoutMsg optional | String | if exists it overrides the default error message |
options.interval optional | Number | interval 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 })
});
Returns
- <Boolean>
return
: true if element is (dis/en)abled