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

有効になるまで待機

(CSSセレクターで選択された)要素が、指定されたミリ秒数だけ(無効/有効)になるまで待機します。指定されたセレクターで複数の要素が照会された場合、少なくとも1つの要素が(無効/有効)であればtrueを返します。

情報

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

使用方法
$(selector).waitForEnabled({ timeout, reverse, timeoutMsg, interval })
パラメータ
名前タイプ詳細
オプション
任意
WaitForOptionswaitForEnabled オプション (任意)
options.timeout
任意
数値ミリ秒単位の時間 (デフォルトはwaitforTimeout設定値に基づいて設定されます)
options.reverse
任意
真偽値trueの場合、反対の状態を待機します (デフォルト: false)
options.timeoutMsg
任意
文字列存在する場合、デフォルトのエラーメッセージをオーバーライドします
options.interval
任意
数値チェック間のインターバル (デフォルト: 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 })
});

ようこそ!何かお困りですか?

WebdriverIO AI Copilot