首页 > 解决方案 > 无法允许可能不是警报的通知

问题描述

正如@DebanjanB 所建议的,在WebDriverWait startsand WebDriverWait ends消息之间清晰可见的弹出窗口可能不是警报。在这种情况下我们如何按允许。

在此处输入图像描述

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 启动

WebDriverWait 结束:消息:等待 PA 创建确认弹出窗口出现超时。

标签: pythonpython-3.xseleniumselenium-chromedriverpython-3.5

解决方案


推荐阅读