I was handling UnexpectedAlertPresentException which often occurs, So I made try-except codes to deal with it. I was about to return the content of Unexpected Alert, So My code is
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)
But it also gives me "NoAlertPresentException" while trying to print the text of the unexpected alert.
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
Could anyone help me deal with this problem?