我发现这个答案https://stackoverflow.com/a/19019311/1998220一直等到警报出现,但我需要相反,所以运行宏的人有时间在代理弹出窗口上进行身份验证。是否与下面的代码相反?
WebDriverWait(browser, 60).until(EC.alert_is_present())
答案 0 :(得分:4)
您可以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