Cant allow notification which may not be an alert [duplicate]

橙三吉。 提交于 2019-12-11 23:38:19

问题


As suggested by @DebanjanB the popup which is clearly visible between the WebDriverWait starts and WebDriverWait ends message may not be an alert. How do we press allow in such case.

chrome_options = webdriver.ChromeOptions()
prefs = { "profile.default_content_setting_values.notifications" : 2 }
chrome_options.add_experimental_option("prefs", prefs)
driver = webdriver.Chrome(chrome_options=chrome_options, executable_path=CHROME_DRIVER_PATH)
driver.get(url)
try:
    print("WebDriverWait starts")
    WebDriverWait(driver, 10).until(EC.alert_is_present(), 'Timed out waiting for PA creation confirmation popup to appear.')
    alert = driver.switch_to.alert
    alert.accept()
    print("alert accepted")
except TimeoutException as e:
    print("WebDriverWait ends: ", e)
    pass

WebDriverWait starts

WebDriverWait ends: Message: Timed out waiting for PA creation confirmation popup to appear.

来源:https://stackoverflow.com/questions/51440682/cant-allow-notification-which-may-not-be-an-alert

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!