[英]Playwright equivalent to Protractor's browser.wait to loop while condition is not met
我試圖找到一種在不滿足特定條件時在 Playwright 中循環的方法。 在量角器中,我可以使用browser.wait
。 在我從 Protractor 遷移到 Playwright 的以下示例中,代碼在 refreshButton 不可見時單擊 refreshButton,一旦它可見,它就單擊 testButton:
await browser.wait(async function () {
return testButton.isPresent().then(async function (present) {
// Refresh the grid until testButton is present
if (present) {
await testButton.click();
return true;
} else {
await refreshButton.click();
return false;
}
});
我已經看到 Playwright 提供了一組調用來等待特定條件,例如 waitForSelector,但我在嘗試讓它們循環工作時遇到了麻煩,因為在承諾之前不會解決簡單的問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.