-
This does not work, the alert gets dismissed unexpectedly However this works fine. The alert shows fine and then accepted. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
That's expected behavior based on how Webdriver works. Calling any type of script while an alert is open will dismiss the alert, and a script is used to verify that the There are also many who consider that a feature because sometimes they want alerts to get dismissed automatically. For your situation, use |
Beta Was this translation helpful? Give feedback.
-
alert_locator locates a button on the page and when clicked the alert is shown. It is not a locator for an object within the alert window. what I am asking about is this: when calling self.click(alert_locator) to display the alert why does it get dismissed right before accepting it? why is not kept ? I just do not get what is the different between self.get_element(alert_locator).click() and self.click(alert_locator) |
Beta Was this translation helpful? Give feedback.
That's expected behavior based on how Webdriver works. Calling any type of script while an alert is open will dismiss the alert, and a script is used to verify that the
document.readyState
of the page iscomplete
after various actions such as clicking. More details on that here: #600There are also many who consider that a feature because sometimes they want alerts to get dismissed automatically. For your situation, use
self.get_element(alert_locator).click()
as needed to make sure the alert stays up if you need it to stay up.