我正在处理经常发生的UnexpectedAlertPresentException,所以我做了try-except代码来处理它。我正要返回意外警报的内容,所以我的代码是
wait = WebDriverWait(driver2,10)
try:
element = wait.until(EC.element_to_be_clickable((By.NAME,'wlike_limit')))
except UnexpectedAlertPresentException:
print("UnexpectedAlertPresentException,",driver2.switch_to.alert.text)
但是在尝试打印意外警报的文本时,它也会给我“ NoAlertPresentException”。
UnexpectedAlertPresentException Traceback (most recent call last)
<ipython-input-52-543c0fff5a64> in <module>
16 try:
---> 17 element = wait.until(EC.element_to_be_clickable((By.NAME,'wlike_limit')))
18 except UnexpectedAlertPresentException:
UnexpectedAlertPresentException: Alert Text:
Message: unexpected alert open: {Alert text: }
(Session info: chrome=84.0.4147.125)
During handling of the above exception,another exception occurred:
NoAlertPresentException Traceback (most recent call last)
<ipython-input-52-543c0fff5a64> in <module>
17 element = wait.until(EC.element_to_be_clickable((By.NAME,'wlike_limit')))
18 except UnexpectedAlertPresentException:
---> 19 print("UnexpectedAlertPresentException,driver2.switch_to.alert.text)
20
有人可以帮我解决这个问题吗?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。