17 from selenium.common.exceptions
import WebDriverException
18 from selenium.webdriver.support
import expected_conditions
as EC
19 from selenium.webdriver.support.ui
import WebDriverWait
32 _next_alert_action = ACCEPT
67 if text
and text != message:
68 raise AssertionError(
"Alert message should have been '%s' but it "
69 "was '%s'." % (text, message))
89 except AssertionError:
92 raise AssertionError(
"Alert with message '%s' present." % text)
124 action = action.upper()
125 text =
' '.join(alert.text.splitlines())
126 if action == self.
ACCEPTACCEPT:
128 elif action == self.
DISMISSDISMISS:
130 elif action != self.
LEAVELEAVE:
131 raise ValueError(
"Invalid alert action '%s'." % action)
138 return wait.until(EC.alert_is_present())
139 except WebDriverException:
140 raise AssertionError(
'Alert not found in %s.'
141 % secs_to_timestr(timeout))
def get_timeout(self, timeout=None)
def input_text_into_alert(self, text, action=ACCEPT, timeout=None)
Types the given text into an input field in an alert.
def handle_alert(self, action=ACCEPT, timeout=None)
Handles the current alert and returns its message.
def _wait_alert(self, timeout=None)
def alert_should_be_present(self, text='', action=ACCEPT, timeout=None)
Verifies that an alert is present and, by default, accepts it.
def alert_should_not_be_present(self, action=ACCEPT, timeout=0)
Verifies that no alert is present.
def _handle_alert(self, alert, action)