Selenium IDE - 等待模态消失

Selenium IDE - Waiting for modal to disappear

如何让 Selenium IDE 等待模式层消失,然后再继续填写表单并单击按钮进入下一步?

这似乎是 waitForElementNotPresent 或 WaitForElementNotVisible 的完美用例。这两个都将等到元素不再出现在屏幕上的默认超时。

您可以使用暂停,但这几乎永远不是正确的答案,因为 waitFor 只会占用超时所需的时间。暂停将始终等待全部时间,这很糟糕。

c# code

我遇到了同样的问题,这段代码已经为我工作了 6 个多月,不再崩溃。

 public static void WaitForModal(this IWebDriver driver)
    {
        wait.Until<IWebDriver>((d) =>
        {
            if (driver.FindElements(By.ClassName("modal-backdrop")).Count == 0)
            {
                return driver;
            }
            return null;
        });
    }

它一直等到不再有 IWebElementclass 为 "modal-backdrop"。

of Happy Bird(非常感谢,还没有机会投票)在 java 中对我来说也很完美,为我节省了很多时间:

WebDriverWait wait = new WebDriverWait(getWebDriver(), 10);
wait.until(new ExpectedCondition<Boolean>() {
                    public Boolean apply(WebDriver driver) {                
                        return  getWebDriver().findElements(By.xpath("//div[contains(@class, 'modal-backdrop')]")).size() == 0;                   
                    }
                });