No Such Alert #1885
Unanswered
atanerkara
asked this question in
Q&A
No Such Alert
#1885
Replies: 1 comment
-
Instead of that specific page, please also test this functionality on any "onine alert() test websites", it works on me. Alternativly you can use this approach too from selenium.webdriver.common.alert import Alert
from selenium.common.exceptions import NoAlertPresentException
try:
alert = Alert(driver)
alert.accept()
except NoAlertPresentException:
print("No alert present") Or you can use javascript to close an alert: from selenium.common.exceptions import UnexpectedAlertPresentException
# if you run this before an alert, it completely blocks the website from showing any alerts
# if you run this during an alert, it will just close the current alert but next alerts will also be able to pop up
try:
driver.execute_script("window.alert = function() {};")
except UnexpectedAlertPresentException:
pass #This error will be raised if an alertbox is already popped By the way for waiting for an alert i use this code: from selenium.webdriver.support import expected_conditions
while True:
if EC.alert_is_present()(driver):
break |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi, when i am trying to switch and accept an alert, it doesnt see the alert and throws exception.
selenium.common.exceptions.NoAlertPresentException: Message: no such alert
Beta Was this translation helpful? Give feedback.
All reactions