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

waitForStable

指定されたミリ秒間、要素が安定する(アニメーションしていない)のを待ちます。セレクタが DOM内で安定している少なくとも1つの要素に一致する場合はtrueを返し、そうでない場合は エラーをスローします。reverse フラグがtrueの場合、コマンドは代わりに セレクタが安定した要素に一致しない場合にtrueを返します。

注意: このコマンドを使用するよりもアニメーションを無効にする方が良いでしょう

使用法
$(selector).waitForStable({ timeout, reverse, timeoutMsg, interval })
パラメータ
名前タイプ詳細
options
オプション
WaitForOptionswaitForStableオプション(オプション)
options.timeout
オプション
Numberミリ秒単位の時間(デフォルトはwaitforTimeout設定値に基づく)
options.reverse
オプション
Booleantrueの場合、反対のことを待ちます(デフォルト:false)
options.timeoutMsg
オプション
String存在する場合、デフォルトのエラーメッセージをオーバーライドします
options.interval
オプション
Numberチェック間の間隔(デフォルト:waitforInterval
index.html
<head>
<style>
div {
width: 200px;
height: 200px;
background-color: red;
}
#has-animation {
animation: 3s 0s alternate slidein;
}
@keyframes slidein {
from {
margin-left: 100%;
width: 300%;
}

to {
margin-left: 0%;
width: 100%;
}
}
</style>
</head>
<body>
<div #has-animation></div>
<div #has-no-animation></div>
</body>

waitForStable.js
it('should detect that element is instable and will wait for the element to become stable', async () => {
const elem = await $('#has-animation')
await elem.waitForStable({ timeout: 3000 });
});
it('should detect that element is stable and will not wait', async () => {
const elem = await $('#has-no-animation')
await elem.waitForStable();
});
戻り値
  • <Boolean> return: 要素が安定している場合はtrue

Welcome! How can I help?

WebdriverIO AI Copilot