微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

等待警报不出现-Selenium / Python

我发现此答案https://stackoverflow.com/a/19019311/1998220一直等待到警报出现为止,但是我需要相反的操作,因此无论运行宏的人都有时间在弹出的代理上进行身份验证.与以下代码相反吗?

webdriverwait(browser, 60).until(EC.alert_is_present())

解决方法:

您可以使用wait for a specific URL, title, or a specific element to be present or visible,但也可以具有特定的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

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐