In brief
Today I cannot get my code here 00 01 works to get javascript alert() box from Python with Selenium WebDriver.
In full
My google search on the topic gave me many results e.g. this one using EC.alert_is_present()
and driver.switch_to_alert()
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
driver = webdriver.Chrome()
driver.get("...some page...")
WebDriverWait(driver, 5).until(EC.alert_is_present())
driver.switch_to_alert().accept()
I follow that and write a simple code on my github here 00 01 trying to access the alert object from Python code. Though I failed with the timeout exception as below i.e. the webdriver cannot get the alert() box object.
Traceback (most recent call last):
File "util/sandbox/my_sandbox/test_alert_box.py", line 49, in <module>
WebDriverWait(driver,10).until(EC.alert_is_present()) #TODO Why alert box not available? We got error here
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/support/wait.py", line 80, in until
raise TimeoutException(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message:
So if you know how to get it work, please share. Thank you!