python - 无法允许可能不是警报的通知
问题描述
正如@DebanjanB 所建议的,在WebDriverWait starts
and 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 创建确认弹出窗口出现超时。
解决方案
推荐阅读
- mysql - MySQL 选择 JSON 数组列是另一个数组子集的行
- python - 如果第一个值匹配,则从特定列中获取值
- spring - Sonatype 扫描显示依赖关系超过 10 年
- angular - Angular 10 - 导航路由器无法正常工作
- python - Python pandas,在定义df之前对数据框的条件
- react-native - 有没有办法在 React Native 上触发“返回”
- python - 如何使用 Django 框架从前端读取 pdf 文件?
- tfs - 如何在 TFS 中为用户授予另一台电脑的权限
- c - cs50 pset3 潮人 lock_pairs 和打印获胜者不工作。我无法修复它
- c# - 如何强制服务在 web api 中运行