waitForEnabled(有効化待機)
指定したミリ秒間、(CSSセレクタで選択された)要素が有効または無効になるのを待ちます。指定されたセレクタによって複数の要素が照会される場合、少なくとも1つの要素が有効または無効であれば「true」を返します。
情報
他の要素コマンドとは異なり、WebdriverIOはこのコマンドを実行するために要素が存在するのを待ちません 。
使用法
$(selector).waitForEnabled({ timeout, reverse, timeoutMsg, interval })
パラメータ
名前 | 型 | 詳細 |
---|---|---|
options オプション | WaitForOptions | waitForEnabledオプション(オプション) |
options.timeout オプション | Number | ミリ秒単位の時間(デフォルトはwaitforTimeout 設定値に基づく) |
options.reverse オプション | Boolean | trueの場合、反対の状態を待ちます(デフォルト: false) |
options.timeoutMsg オプション | String | 存在する場合、デフォルトのエラーメッセージを上書きします |
options.interval オプション | Number | チェック間の間隔(デフォルト: waitforInterval ) |
例
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 })
});
戻り値
- <Boolean>
return
: 要素が有効または無効であれば true