メインコンテンツにスキップ

waitForEnabled(有効化待機)

指定したミリ秒間、(CSSセレクタで選択された)要素が有効または無効になるのを待ちます。指定されたセレクタによって複数の要素が照会される場合、少なくとも1つの要素が有効または無効であれば「true」を返します。

情報

他の要素コマンドとは異なり、WebdriverIOはこのコマンドを実行するために要素が存在するのを待ちません。

使用法
$(selector).waitForEnabled({ timeout, reverse, timeoutMsg, interval })
パラメータ
名前詳細
options
オプション
WaitForOptionswaitForEnabledオプション(オプション)
options.timeout
オプション
Numberミリ秒単位の時間(デフォルトはwaitforTimeout設定値に基づく)
options.reverse
オプション
Booleantrueの場合、反対の状態を待ちます(デフォルト: 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

Welcome! How can I help?

WebdriverIO AI Copilot