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

存在するまで待つ

指定されたミリ秒数の間、要素がDOM内に存在するまで待機します。セレクターがDOM内に存在する少なくとも1つの要素と一致する場合、trueを返します。それ以外の場合は、エラーをスローします。 reverseフラグがtrueの場合、コマンドはセレクターがどの要素とも一致しない場合にtrueを返します。

...情報

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

使用方法
$(selector).waitForExist({ timeout, reverse, timeoutMsg, interval })
パラメータ
名前タイプ詳細
オプション
オプション
WaitForOptionswaitForEnabled オプション (オプション)
options.timeout
オプション
数値ミリ秒単位の時間 (デフォルトはwaitforTimeout設定値に基づいて設定されます)
options.reverse
オプション
真偽値trueの場合、反対を待ちます (デフォルト: false)
options.timeoutMsg
オプション
文字列存在する場合、デフォルトのエラーメッセージをオーバーライドします
options.interval
オプション
数値チェック間隔 (デフォルト: waitforInterval)
waitForExistSyncExample.js
it('should display a notification message after successful form submit', async () => {
const form = await $('form');
const notification = await $('.notification');
await form.$(".send").click();
await notification.waitForExist({ timeout: 5000 });
expect(await notification.getText()).to.be.equal('Data transmitted successfully!')
});
it('should remove a message after successful form submit', async () => {
const form = await $('form');
const message = await $('.message');
await form.$(".send").click();
await message.waitForExist({ reverse: true });
});

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

WebdriverIO AI Copilot