等到警报不存在 - Selenium/Python

Mic*_*air 5 python selenium

我找到了这个答案/sf/answers/1331351801/等待警报出现,但我需要相反的内容,以便运行宏的人有时间在代理弹出时进行身份验证。下面的代码有相反的吗?

WebDriverWait(browser, 60).until(EC.alert_is_present())
Run Code Online (Sandbox Code Playgroud)

ale*_*cxe 7

您可以等待特定 URL、标题或特定元素出现或可见,但您也可以拥有特定的alert_is_not_present 自定义预期条件

class alert_is_not_present(object):
    """ Expect an alert to not to be present."""
    def __call__(self, driver):
        try:
            alert = driver.switch_to.alert
            alert.text
            return False
        except NoAlertPresentException:
            return True
Run Code Online (Sandbox Code Playgroud)