2
我找到了這個答案https://stackoverflow.com/a/19019311/1998220,一直等到警報出現,但我需要相反的結果,所以無論誰運行宏,都有時間在代理彈出窗口進行身份驗證。是否有與下面的代碼相反的內容?等到警報不存在 - Selenium/Python
WebDriverWait(browser, 60).until(EC.alert_is_present())
我找到了這個答案https://stackoverflow.com/a/19019311/1998220,一直等到警報出現,但我需要相反的結果,所以無論誰運行宏,都有時間在代理彈出窗口進行身份驗證。是否有與下面的代碼相反的內容?等到警報不存在 - Selenium/Python
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