Categories
javascript python selenium selenium-chromedriver selenium-webdriver

Python – Selenium test gets stuck on trying to accept an alert

I am new to python-selenium and was implementing an automation script which checks for a specific mail and sends it to intended client from outlook office mail. On clicking on forward mail button , a new window opens along with an alert which has options to select “OK” or “Cancel”.I am able to switch to window using window_handles and also switch to the corresponding alert, But accepting the alert gets stalled and nothing happens until i manually go and press the ok button.

window_handle_names = self.driver.window_handles
time.sleep(10)
self.driver.switch_to_window(window_handle_names[1])
time.sleep(10)
alert = self.driver.switch_to_alert()
alert.accept()

I am using a dom based model where i have subclassed webdriver and webelements. I could see that execution occurs till switch_to_alert(), but as soon as accept is encountered everything stalls
Note:execution is done in chrome, i haven’t tested the same in Firefox