mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 03:15:11 +00:00
Bug 1503015 - [wdspec] Add user prompt tests for element retrieval commands. r=ato
Depends on D10181 Differential Revision: https://phabricator.services.mozilla.com/D10182 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
81bcc04ac0
commit
b604174729
@ -0,0 +1,121 @@
|
||||
# META: timeout=long
|
||||
|
||||
import pytest
|
||||
|
||||
from tests.support.asserts import (
|
||||
assert_error,
|
||||
assert_same_element,
|
||||
assert_success,
|
||||
assert_dialog_handled,
|
||||
)
|
||||
from tests.support.inline import inline
|
||||
|
||||
|
||||
def find_element(session, using, value):
|
||||
return session.transport.send(
|
||||
"POST", "session/{session_id}/element".format(**vars(session)),
|
||||
{"using": using, "value": value})
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def check_user_prompt_closed_without_exception(session, create_dialog):
|
||||
def check_user_prompt_closed_without_exception(dialog_type, retval):
|
||||
session.url = inline("<p>bar</p>")
|
||||
element = session.find.css("p", all=False)
|
||||
|
||||
create_dialog(dialog_type, text=dialog_type)
|
||||
|
||||
response = find_element(session, "css selector", "p")
|
||||
value = assert_success(response)
|
||||
|
||||
assert_dialog_handled(session, expected_text=dialog_type, expected_retval=retval)
|
||||
|
||||
assert_same_element(session, value, element)
|
||||
|
||||
return check_user_prompt_closed_without_exception
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def check_user_prompt_closed_with_exception(session, create_dialog):
|
||||
def check_user_prompt_closed_with_exception(dialog_type, retval):
|
||||
session.url = inline("<p>bar</p>")
|
||||
|
||||
create_dialog(dialog_type, text=dialog_type)
|
||||
|
||||
response = find_element(session, "css selector", "p")
|
||||
assert_error(response, "unexpected alert open")
|
||||
|
||||
assert_dialog_handled(session, expected_text=dialog_type, expected_retval=retval)
|
||||
|
||||
return check_user_prompt_closed_with_exception
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def check_user_prompt_not_closed_but_exception(session, create_dialog):
|
||||
def check_user_prompt_not_closed_but_exception(dialog_type):
|
||||
session.url = inline("<p>bar</p>")
|
||||
|
||||
create_dialog(dialog_type, text=dialog_type)
|
||||
|
||||
response = find_element(session, "css selector", "p")
|
||||
assert_error(response, "unexpected alert open")
|
||||
|
||||
assert session.alert.text == dialog_type
|
||||
session.alert.dismiss()
|
||||
|
||||
return check_user_prompt_not_closed_but_exception
|
||||
|
||||
|
||||
@pytest.mark.capabilities({"unhandledPromptBehavior": "accept"})
|
||||
@pytest.mark.parametrize("dialog_type, retval", [
|
||||
("alert", None),
|
||||
("confirm", True),
|
||||
("prompt", ""),
|
||||
])
|
||||
def test_accept(check_user_prompt_closed_without_exception, dialog_type, retval):
|
||||
check_user_prompt_closed_without_exception(dialog_type, retval)
|
||||
|
||||
|
||||
@pytest.mark.capabilities({"unhandledPromptBehavior": "accept and notify"})
|
||||
@pytest.mark.parametrize("dialog_type, retval", [
|
||||
("alert", None),
|
||||
("confirm", True),
|
||||
("prompt", ""),
|
||||
])
|
||||
def test_accept_and_notify(check_user_prompt_closed_with_exception, dialog_type, retval):
|
||||
check_user_prompt_closed_with_exception(dialog_type, retval)
|
||||
|
||||
|
||||
@pytest.mark.capabilities({"unhandledPromptBehavior": "dismiss"})
|
||||
@pytest.mark.parametrize("dialog_type, retval", [
|
||||
("alert", None),
|
||||
("confirm", False),
|
||||
("prompt", None),
|
||||
])
|
||||
def test_dismiss(check_user_prompt_closed_without_exception, dialog_type, retval):
|
||||
check_user_prompt_closed_without_exception(dialog_type, retval)
|
||||
|
||||
|
||||
@pytest.mark.capabilities({"unhandledPromptBehavior": "dismiss and notify"})
|
||||
@pytest.mark.parametrize("dialog_type, retval", [
|
||||
("alert", None),
|
||||
("confirm", False),
|
||||
("prompt", None),
|
||||
])
|
||||
def test_dismiss_and_notify(check_user_prompt_closed_with_exception, dialog_type, retval):
|
||||
check_user_prompt_closed_with_exception(dialog_type, retval)
|
||||
|
||||
|
||||
@pytest.mark.capabilities({"unhandledPromptBehavior": "ignore"})
|
||||
@pytest.mark.parametrize("dialog_type", ["alert", "confirm", "prompt"])
|
||||
def test_ignore(check_user_prompt_not_closed_but_exception, dialog_type):
|
||||
check_user_prompt_not_closed_but_exception(dialog_type)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("dialog_type, retval", [
|
||||
("alert", None),
|
||||
("confirm", False),
|
||||
("prompt", None),
|
||||
])
|
||||
def test_default(check_user_prompt_closed_with_exception, dialog_type, retval):
|
||||
check_user_prompt_closed_with_exception(dialog_type, retval)
|
@ -0,0 +1,126 @@
|
||||
# META: timeout=long
|
||||
|
||||
import pytest
|
||||
|
||||
from tests.support.asserts import (
|
||||
assert_error,
|
||||
assert_same_element,
|
||||
assert_success,
|
||||
assert_dialog_handled,
|
||||
)
|
||||
from tests.support.inline import inline
|
||||
|
||||
|
||||
def find_element(session, element_id, using, value):
|
||||
return session.transport.send(
|
||||
"POST", "session/{session_id}/element/{element_id}/element".format(
|
||||
session_id=session.session_id,
|
||||
element_id=element_id),
|
||||
{"using": using, "value": value})
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def check_user_prompt_closed_without_exception(session, create_dialog):
|
||||
def check_user_prompt_closed_without_exception(dialog_type, retval):
|
||||
session.url = inline("<div><p>bar</p><div>")
|
||||
outer_element = session.find.css("div", all=False)
|
||||
inner_element = session.find.css("p", all=False)
|
||||
|
||||
create_dialog(dialog_type, text=dialog_type)
|
||||
|
||||
response = find_element(session, outer_element.id, "css selector", "p")
|
||||
value = assert_success(response)
|
||||
|
||||
assert_dialog_handled(session, expected_text=dialog_type, expected_retval=retval)
|
||||
|
||||
assert_same_element(session, value, inner_element)
|
||||
|
||||
return check_user_prompt_closed_without_exception
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def check_user_prompt_closed_with_exception(session, create_dialog):
|
||||
def check_user_prompt_closed_with_exception(dialog_type, retval):
|
||||
session.url = inline("<div><p>bar</p><div>")
|
||||
outer_element = session.find.css("div", all=False)
|
||||
|
||||
create_dialog(dialog_type, text=dialog_type)
|
||||
|
||||
response = find_element(session, outer_element.id, "css selector", "p")
|
||||
assert_error(response, "unexpected alert open")
|
||||
|
||||
assert_dialog_handled(session, expected_text=dialog_type, expected_retval=retval)
|
||||
|
||||
return check_user_prompt_closed_with_exception
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def check_user_prompt_not_closed_but_exception(session, create_dialog):
|
||||
def check_user_prompt_not_closed_but_exception(dialog_type):
|
||||
session.url = inline("<div><p>bar</p><div>")
|
||||
outer_element = session.find.css("div", all=False)
|
||||
|
||||
create_dialog(dialog_type, text=dialog_type)
|
||||
|
||||
response = find_element(session, outer_element.id, "css selector", "p")
|
||||
assert_error(response, "unexpected alert open")
|
||||
|
||||
assert session.alert.text == dialog_type
|
||||
session.alert.dismiss()
|
||||
|
||||
return check_user_prompt_not_closed_but_exception
|
||||
|
||||
|
||||
@pytest.mark.capabilities({"unhandledPromptBehavior": "accept"})
|
||||
@pytest.mark.parametrize("dialog_type, retval", [
|
||||
("alert", None),
|
||||
("confirm", True),
|
||||
("prompt", ""),
|
||||
])
|
||||
def test_accept(check_user_prompt_closed_without_exception, dialog_type, retval):
|
||||
check_user_prompt_closed_without_exception(dialog_type, retval)
|
||||
|
||||
|
||||
@pytest.mark.capabilities({"unhandledPromptBehavior": "accept and notify"})
|
||||
@pytest.mark.parametrize("dialog_type, retval", [
|
||||
("alert", None),
|
||||
("confirm", True),
|
||||
("prompt", ""),
|
||||
])
|
||||
def test_accept_and_notify(check_user_prompt_closed_with_exception, dialog_type, retval):
|
||||
check_user_prompt_closed_with_exception(dialog_type, retval)
|
||||
|
||||
|
||||
@pytest.mark.capabilities({"unhandledPromptBehavior": "dismiss"})
|
||||
@pytest.mark.parametrize("dialog_type, retval", [
|
||||
("alert", None),
|
||||
("confirm", False),
|
||||
("prompt", None),
|
||||
])
|
||||
def test_dismiss(check_user_prompt_closed_without_exception, dialog_type, retval):
|
||||
check_user_prompt_closed_without_exception(dialog_type, retval)
|
||||
|
||||
|
||||
@pytest.mark.capabilities({"unhandledPromptBehavior": "dismiss and notify"})
|
||||
@pytest.mark.parametrize("dialog_type, retval", [
|
||||
("alert", None),
|
||||
("confirm", False),
|
||||
("prompt", None),
|
||||
])
|
||||
def test_dismiss_and_notify(check_user_prompt_closed_with_exception, dialog_type, retval):
|
||||
check_user_prompt_closed_with_exception(dialog_type, retval)
|
||||
|
||||
|
||||
@pytest.mark.capabilities({"unhandledPromptBehavior": "ignore"})
|
||||
@pytest.mark.parametrize("dialog_type", ["alert", "confirm", "prompt"])
|
||||
def test_ignore(check_user_prompt_not_closed_but_exception, dialog_type):
|
||||
check_user_prompt_not_closed_but_exception(dialog_type)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("dialog_type, retval", [
|
||||
("alert", None),
|
||||
("confirm", False),
|
||||
("prompt", None),
|
||||
])
|
||||
def test_default(check_user_prompt_closed_with_exception, dialog_type, retval):
|
||||
check_user_prompt_closed_with_exception(dialog_type, retval)
|
@ -0,0 +1,123 @@
|
||||
# META: timeout=long
|
||||
|
||||
import pytest
|
||||
|
||||
from tests.support.asserts import (
|
||||
assert_error,
|
||||
assert_same_element,
|
||||
assert_success,
|
||||
assert_dialog_handled,
|
||||
)
|
||||
from tests.support.inline import inline
|
||||
|
||||
|
||||
def find_elements(session, using, value):
|
||||
return session.transport.send(
|
||||
"POST", "session/{session_id}/elements".format(**vars(session)),
|
||||
{"using": using, "value": value})
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def check_user_prompt_closed_without_exception(session, create_dialog):
|
||||
def check_user_prompt_closed_without_exception(dialog_type, retval):
|
||||
session.url = inline("<p>bar</p>")
|
||||
element = session.find.css("p", all=False)
|
||||
|
||||
create_dialog(dialog_type, text=dialog_type)
|
||||
|
||||
response = find_elements(session, "css selector", "p")
|
||||
value = assert_success(response)
|
||||
assert isinstance(value, list)
|
||||
assert len(value) == 1
|
||||
|
||||
assert_dialog_handled(session, expected_text=dialog_type, expected_retval=retval)
|
||||
|
||||
assert_same_element(session, value[0], element)
|
||||
|
||||
return check_user_prompt_closed_without_exception
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def check_user_prompt_closed_with_exception(session, create_dialog):
|
||||
def check_user_prompt_closed_with_exception(dialog_type, retval):
|
||||
session.url = inline("<p>bar</p>")
|
||||
|
||||
create_dialog(dialog_type, text=dialog_type)
|
||||
|
||||
response = find_elements(session, "css selector", "p")
|
||||
assert_error(response, "unexpected alert open")
|
||||
|
||||
assert_dialog_handled(session, expected_text=dialog_type, expected_retval=retval)
|
||||
|
||||
return check_user_prompt_closed_with_exception
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def check_user_prompt_not_closed_but_exception(session, create_dialog):
|
||||
def check_user_prompt_not_closed_but_exception(dialog_type):
|
||||
session.url = inline("<p>bar</p>")
|
||||
|
||||
create_dialog(dialog_type, text=dialog_type)
|
||||
|
||||
response = find_elements(session, "css selector", "p")
|
||||
assert_error(response, "unexpected alert open")
|
||||
|
||||
assert session.alert.text == dialog_type
|
||||
session.alert.dismiss()
|
||||
|
||||
return check_user_prompt_not_closed_but_exception
|
||||
|
||||
|
||||
@pytest.mark.capabilities({"unhandledPromptBehavior": "accept"})
|
||||
@pytest.mark.parametrize("dialog_type, retval", [
|
||||
("alert", None),
|
||||
("confirm", True),
|
||||
("prompt", ""),
|
||||
])
|
||||
def test_accept(check_user_prompt_closed_without_exception, dialog_type, retval):
|
||||
check_user_prompt_closed_without_exception(dialog_type, retval)
|
||||
|
||||
|
||||
@pytest.mark.capabilities({"unhandledPromptBehavior": "accept and notify"})
|
||||
@pytest.mark.parametrize("dialog_type, retval", [
|
||||
("alert", None),
|
||||
("confirm", True),
|
||||
("prompt", ""),
|
||||
])
|
||||
def test_accept_and_notify(check_user_prompt_closed_with_exception, dialog_type, retval):
|
||||
check_user_prompt_closed_with_exception(dialog_type, retval)
|
||||
|
||||
|
||||
@pytest.mark.capabilities({"unhandledPromptBehavior": "dismiss"})
|
||||
@pytest.mark.parametrize("dialog_type, retval", [
|
||||
("alert", None),
|
||||
("confirm", False),
|
||||
("prompt", None),
|
||||
])
|
||||
def test_dismiss(check_user_prompt_closed_without_exception, dialog_type, retval):
|
||||
check_user_prompt_closed_without_exception(dialog_type, retval)
|
||||
|
||||
|
||||
@pytest.mark.capabilities({"unhandledPromptBehavior": "dismiss and notify"})
|
||||
@pytest.mark.parametrize("dialog_type, retval", [
|
||||
("alert", None),
|
||||
("confirm", False),
|
||||
("prompt", None),
|
||||
])
|
||||
def test_dismiss_and_notify(check_user_prompt_closed_with_exception, dialog_type, retval):
|
||||
check_user_prompt_closed_with_exception(dialog_type, retval)
|
||||
|
||||
|
||||
@pytest.mark.capabilities({"unhandledPromptBehavior": "ignore"})
|
||||
@pytest.mark.parametrize("dialog_type", ["alert", "confirm", "prompt"])
|
||||
def test_ignore(check_user_prompt_not_closed_but_exception, dialog_type):
|
||||
check_user_prompt_not_closed_but_exception(dialog_type)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("dialog_type, retval", [
|
||||
("alert", None),
|
||||
("confirm", False),
|
||||
("prompt", None),
|
||||
])
|
||||
def test_default(check_user_prompt_closed_with_exception, dialog_type, retval):
|
||||
check_user_prompt_closed_with_exception(dialog_type, retval)
|
@ -0,0 +1,128 @@
|
||||
# META: timeout=long
|
||||
|
||||
import pytest
|
||||
|
||||
from tests.support.asserts import (
|
||||
assert_error,
|
||||
assert_same_element,
|
||||
assert_success,
|
||||
assert_dialog_handled,
|
||||
)
|
||||
from tests.support.inline import inline
|
||||
|
||||
|
||||
def find_elements(session, element_id, using, value):
|
||||
return session.transport.send(
|
||||
"POST", "session/{session_id}/element/{element_id}/elements".format(
|
||||
session_id=session.session_id,
|
||||
element_id=element_id),
|
||||
{"using": using, "value": value})
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def check_user_prompt_closed_without_exception(session, create_dialog):
|
||||
def check_user_prompt_closed_without_exception(dialog_type, retval):
|
||||
session.url = inline("<div><p>bar</p><div>")
|
||||
outer_element = session.find.css("div", all=False)
|
||||
inner_element = session.find.css("p", all=False)
|
||||
|
||||
create_dialog(dialog_type, text=dialog_type)
|
||||
|
||||
response = find_elements(session, outer_element.id, "css selector", "p")
|
||||
value = assert_success(response)
|
||||
assert isinstance(value, list)
|
||||
assert len(value) == 1
|
||||
|
||||
assert_dialog_handled(session, expected_text=dialog_type, expected_retval=retval)
|
||||
|
||||
assert_same_element(session, value[0], inner_element)
|
||||
|
||||
return check_user_prompt_closed_without_exception
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def check_user_prompt_closed_with_exception(session, create_dialog):
|
||||
def check_user_prompt_closed_with_exception(dialog_type, retval):
|
||||
session.url = inline("<div><p>bar</p><div>")
|
||||
outer_element = session.find.css("div", all=False)
|
||||
|
||||
create_dialog(dialog_type, text=dialog_type)
|
||||
|
||||
response = find_elements(session, outer_element.id, "css selector", "p")
|
||||
assert_error(response, "unexpected alert open")
|
||||
|
||||
assert_dialog_handled(session, expected_text=dialog_type, expected_retval=retval)
|
||||
|
||||
return check_user_prompt_closed_with_exception
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def check_user_prompt_not_closed_but_exception(session, create_dialog):
|
||||
def check_user_prompt_not_closed_but_exception(dialog_type):
|
||||
session.url = inline("<div><p>bar</p><div>")
|
||||
outer_element = session.find.css("div", all=False)
|
||||
|
||||
create_dialog(dialog_type, text=dialog_type)
|
||||
|
||||
response = find_elements(session, outer_element.id, "css selector", "p")
|
||||
assert_error(response, "unexpected alert open")
|
||||
|
||||
assert session.alert.text == dialog_type
|
||||
session.alert.dismiss()
|
||||
|
||||
return check_user_prompt_not_closed_but_exception
|
||||
|
||||
|
||||
@pytest.mark.capabilities({"unhandledPromptBehavior": "accept"})
|
||||
@pytest.mark.parametrize("dialog_type, retval", [
|
||||
("alert", None),
|
||||
("confirm", True),
|
||||
("prompt", ""),
|
||||
])
|
||||
def test_accept(check_user_prompt_closed_without_exception, dialog_type, retval):
|
||||
check_user_prompt_closed_without_exception(dialog_type, retval)
|
||||
|
||||
|
||||
@pytest.mark.capabilities({"unhandledPromptBehavior": "accept and notify"})
|
||||
@pytest.mark.parametrize("dialog_type, retval", [
|
||||
("alert", None),
|
||||
("confirm", True),
|
||||
("prompt", ""),
|
||||
])
|
||||
def test_accept_and_notify(check_user_prompt_closed_with_exception, dialog_type, retval):
|
||||
check_user_prompt_closed_with_exception(dialog_type, retval)
|
||||
|
||||
|
||||
@pytest.mark.capabilities({"unhandledPromptBehavior": "dismiss"})
|
||||
@pytest.mark.parametrize("dialog_type, retval", [
|
||||
("alert", None),
|
||||
("confirm", False),
|
||||
("prompt", None),
|
||||
])
|
||||
def test_dismiss(check_user_prompt_closed_without_exception, dialog_type, retval):
|
||||
check_user_prompt_closed_without_exception(dialog_type, retval)
|
||||
|
||||
|
||||
@pytest.mark.capabilities({"unhandledPromptBehavior": "dismiss and notify"})
|
||||
@pytest.mark.parametrize("dialog_type, retval", [
|
||||
("alert", None),
|
||||
("confirm", False),
|
||||
("prompt", None),
|
||||
])
|
||||
def test_dismiss_and_notify(check_user_prompt_closed_with_exception, dialog_type, retval):
|
||||
check_user_prompt_closed_with_exception(dialog_type, retval)
|
||||
|
||||
|
||||
@pytest.mark.capabilities({"unhandledPromptBehavior": "ignore"})
|
||||
@pytest.mark.parametrize("dialog_type", ["alert", "confirm", "prompt"])
|
||||
def test_ignore(check_user_prompt_not_closed_but_exception, dialog_type):
|
||||
check_user_prompt_not_closed_but_exception(dialog_type)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("dialog_type, retval", [
|
||||
("alert", None),
|
||||
("confirm", False),
|
||||
("prompt", None),
|
||||
])
|
||||
def test_default(check_user_prompt_closed_with_exception, dialog_type, retval):
|
||||
check_user_prompt_closed_with_exception(dialog_type, retval)
|
Loading…
Reference in New Issue
Block a user