2019-08-17 14:47:11 +08:00
|
|
|
from seleniumbase import BaseCase
|
|
|
|
|
|
|
|
|
2021-03-11 06:27:52 +08:00
|
|
|
class HandleAlertTests(BaseCase):
|
2019-08-17 14:47:11 +08:00
|
|
|
def test_alerts(self):
|
2021-02-25 15:34:07 +08:00
|
|
|
if self.browser == "safari":
|
|
|
|
self.skip("This test doesn't run on Safari! (alert issues)")
|
2019-08-17 14:47:11 +08:00
|
|
|
self.open("about:blank")
|
2021-02-25 15:34:07 +08:00
|
|
|
self.execute_script('window.alert("ALERT!!!");')
|
2020-05-28 15:37:44 +08:00
|
|
|
self.sleep(1) # Not needed (Lets you see the alert pop up)
|
|
|
|
self.accept_alert()
|
|
|
|
self.sleep(1) # Not needed (Lets you see the alert go away)
|
2020-04-23 00:45:11 +08:00
|
|
|
self.execute_script('window.prompt("My Prompt","defaultText");')
|
2020-05-28 15:37:44 +08:00
|
|
|
self.sleep(1) # Not needed (Lets you see the alert pop up)
|
|
|
|
alert = self.switch_to_alert()
|
|
|
|
self.assert_equal(alert.text, "My Prompt") # Not input field
|
|
|
|
self.dismiss_alert()
|
|
|
|
self.sleep(1) # Not needed (Lets you see the alert go away)
|