我正在处理经常发生的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
有人可以帮我解决这个问题吗?