Unreviewed. Update W3C WebDriver imported tests.
[WebKit-https.git] / WebDriverTests / imported / w3c / webdriver / tests / user_prompts / dismiss_alert.py
1 from tests.support.asserts import assert_error, assert_success
2 from tests.support.inline import inline
3
4
5 def dismiss_alert(session):
6     return session.transport.send("POST", "session/{session_id}/alert/dismiss"
7                                   .format(session_id=session.session_id))
8
9
10 # 18.1 Dismiss Alert
11
12 def test_no_browsing_context(session, create_window):
13     # 18.1 step 1
14     session.window_handle = create_window()
15     session.close()
16
17     response = dismiss_alert(session)
18     assert_error(response, "no such window")
19
20
21 def test_no_user_prompt(session):
22     # 18.1 step 2
23     response = dismiss_alert(session)
24     assert_error(response, "no such alert")
25
26
27 def test_dismiss_alert(session):
28     # 18.1 step 3
29     session.url = inline("<script>window.alert('Hello');</script>")
30     response = dismiss_alert(session)
31     assert_success(response)
32
33
34 def test_dismiss_confirm(session):
35     # 18.1 step 3
36     session.url = inline("<script>window.result = window.confirm('Hello');</script>")
37     response = dismiss_alert(session)
38     assert_success(response)
39     assert session.execute_script("return window.result;") is False
40
41
42 def test_dismiss_prompt(session):
43     # 18.1 step 3
44     session.url = inline("<script>window.result = window.prompt('Enter Your Name: ', 'Federer');</script>")
45     response = dismiss_alert(session)
46     assert_success(response)
47     assert session.execute_script("return window.result") is None