【发布时间】:2018-11-10 19:22:40
【问题描述】:
我正在尝试进行警报异常处理,我尝试了一些选项,但我似乎无法让脚本尝试异常,它只是出错了。
#Add Alert Bypass
try:
driver.switch_to.default_content()
except NoAlertPresentException:
print('Alert Popup')
alert = driver.switch_to.alert()
alert.dismiss()
错误信息:
Message: unexpected alert open: {Alert text : ...}
【问题讨论】:
-
你能告诉我们警报网址或代码吗
-
您正在尝试处理警报,以防没有警报!也许您应该在
try和except块中切换代码? -
这是尝试,除了...
-
切换到默认内容不应导致触发警报。请发布导致警报触发的相关代码。这就是您需要
try-catch的地方。
标签: python selenium error-handling