انتقل إلى المحتوى الرئيسي

انتظر حتى يستقر

انتظر العنصر للمدة المحددة من الميلي ثانية حتى يستقر (لا يتحرك). يُرجع القيمة true إذا كان المحدد يطابق على الأقل عنصرًا واحدًا مستقرًا في DOM، وإلا فإنه يُطلق خطأ. إذا كانت علامة reverse صحيحة، فستعيد الأمر بدلاً من ذلك القيمة true إذا كان المحدد لا يطابق أي عناصر مستقرة.

ملاحظة: من الأفضل تعطيل الرسوم المتحركة بدلاً من استخدام هذا الأمر

الاستخدام
$(selector).waitForStable({ timeout, reverse, timeoutMsg, interval })
المعلمات
الاسمالنوعالتفاصيل
options
اختياري
WaitForOptionsخيارات waitForStable (اختياري)
options.timeout
اختياري
Numberالوقت بالميلي ثانية (الإعداد الافتراضي يعتمد على قيمة التكوين waitforTimeout)
options.reverse
اختياري
Booleanإذا كانت القيمة true فإنه ينتظر العكس (الافتراضي: 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