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

waitForExist

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

情報

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

使用法
$(selector).waitForExist({ timeout, reverse, timeoutMsg, interval })
パラメータ
名前詳細
options
オプション
WaitForOptionswaitForEnabledオプション(オプション)
options.timeout
オプション
Numberミリ秒単位の時間(デフォルトはwaitforTimeout設定値に基づく)
options.reverse
オプション
Booleantrueの場合、反対の結果を待ちます(デフォルト:false)
options.timeoutMsg
オプション
String存在する場合、デフォルトのエラーメッセージを上書きします
options.interval
オプション
Numberチェック間の間隔(デフォルト: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 });
});
戻り値
  • <Boolean> return: 要素が存在する場合(またはフラグが設定されている場合は存在しない場合)true

Welcome! How can I help?

WebdriverIO AI Copilot