MCPcopy Create free account
hub / github.com/seleniumbase/SeleniumBase / test_alerts

Method test_alerts

examples/handle_alert_test.py:6–22  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

4
5class HandleAlertTests(BaseCase):
6 def test_alerts(self):
7 self.goto("about:blank")
8 self.execute_script('window.alert("ALERT!!!");')
9 self.sleep(1) # Not needed (Lets you see the alert pop up)
10 self.assert_true(self.is_alert_present())
11 self.accept_alert()
12 self.sleep(1) # Not needed (Lets you see the alert go away)
13 self.execute_script('window.prompt("My Prompt","defaultText");')
14 self.sleep(1) # Not needed (Lets you see the alert pop up)
15 alert = self.switch_to_alert()
16 self.assert_equal(alert.text, "My Prompt") # Not input field
17 self.dismiss_alert()
18 self.sleep(1) # Not needed (Lets you see the alert go away)
19 self.assert_false(self.is_alert_present())
20 if self.browser == "safari" and self._reuse_session:
21 # Alerts can freeze Safari if reusing the browser session
22 self.driver.quit()

Callers

nothing calls this directly

Calls 11

accept_alertMethod · 0.80
switch_to_alertMethod · 0.80
dismiss_alertMethod · 0.80
gotoMethod · 0.45
execute_scriptMethod · 0.45
sleepMethod · 0.45
assert_trueMethod · 0.45
is_alert_presentMethod · 0.45
assert_equalMethod · 0.45
assert_falseMethod · 0.45
quitMethod · 0.45

Tested by

no test coverage detected