Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/WebDriverTests/imported/w3c/webdriver/tests/conftest.py b/WebDriverTests/imported/w3c/webdriver/tests/conftest.py
- index e1491a68026..341377cfd2c 100644
- --- a/WebDriverTests/imported/w3c/webdriver/tests/conftest.py
- +++ b/WebDriverTests/imported/w3c/webdriver/tests/conftest.py
- @@ -1,7 +1,7 @@
- import pytest
- from tests.support.fixtures import (
- configuration, create_dialog, create_frame, create_window, http,
- - new_session, server_config, session, url)
- + new_session, overwrite_capabilites, server_config, session, url)
- pytest.fixture(scope="session")(configuration)
- pytest.fixture()(create_dialog)
- @@ -9,6 +9,7 @@ pytest.fixture()(create_frame)
- pytest.fixture()(create_window)
- pytest.fixture()(http)
- pytest.fixture(scope="function")(new_session)
- +pytest.fixture()(overwrite_capabilites)
- pytest.fixture()(server_config)
- pytest.fixture(scope="function")(session)
- pytest.fixture()(url)
- diff --git a/WebDriverTests/imported/w3c/webdriver/tests/contexts/maximize_window.py b/WebDriverTests/imported/w3c/webdriver/tests/contexts/maximize_window.py
- index 4173b170881..527f30e0262 100644
- --- a/WebDriverTests/imported/w3c/webdriver/tests/contexts/maximize_window.py
- +++ b/WebDriverTests/imported/w3c/webdriver/tests/contexts/maximize_window.py
- @@ -39,7 +39,7 @@ def test_handle_prompt_ignore():
- """TODO"""
- -def test_handle_prompt_accept(new_session):
- +def test_handle_prompt_accept(new_session, overwrite_capabilites):
- """
- 3. Handle any user prompts and return its value if it is an error.
- @@ -59,7 +59,7 @@ def test_handle_prompt_accept(new_session):
- Accept the current user prompt.
- """
- - _, session = new_session({"alwaysMatch": {"unhandledPromptBehavior": "accept"}})
- + _, session = new_session(overwrite_capabilites({"alwaysMatch": {"unhandledPromptBehavior": "accept"}}))
- session.url = inline("<title>WD doc title</title>")
- create_dialog(session)("alert", text="dismiss #1", result_var="dismiss1")
- diff --git a/WebDriverTests/imported/w3c/webdriver/tests/cookies/delete_cookie.py b/WebDriverTests/imported/w3c/webdriver/tests/cookies/delete_cookie.py
- index adb9674909c..5aadcd74083 100644
- --- a/WebDriverTests/imported/w3c/webdriver/tests/cookies/delete_cookie.py
- +++ b/WebDriverTests/imported/w3c/webdriver/tests/cookies/delete_cookie.py
- @@ -34,7 +34,7 @@ def test_handle_prompt_ignore():
- """TODO"""
- -def test_handle_prompt_accept(new_session):
- +def test_handle_prompt_accept(new_session, overwrite_capabilites):
- """
- 2. Handle any user prompts and return its value if it is an error.
- @@ -54,7 +54,7 @@ def test_handle_prompt_accept(new_session):
- Accept the current user prompt.
- """
- - _, session = new_session({"alwaysMatch": {"unhandledPromptBehavior": "accept"}})
- + _, session = new_session(overwrite_capabilites({"alwaysMatch": {"unhandledPromptBehavior": "accept"}}))
- session.url = inline("<title>WD doc title</title>")
- create_dialog(session)("alert", text="dismiss #1", result_var="dismiss1")
- diff --git a/WebDriverTests/imported/w3c/webdriver/tests/element_retrieval/get_active_element.py b/WebDriverTests/imported/w3c/webdriver/tests/element_retrieval/get_active_element.py
- index 8286633e89d..3a3891557cb 100644
- --- a/WebDriverTests/imported/w3c/webdriver/tests/element_retrieval/get_active_element.py
- +++ b/WebDriverTests/imported/w3c/webdriver/tests/element_retrieval/get_active_element.py
- @@ -43,8 +43,8 @@ def test_closed_context(session, create_window):
- # [...]
- #
- # 3. Return success.
- -def test_handle_prompt_dismiss(new_session):
- - _, session = new_session({"alwaysMatch": {"unhandledPromptBehavior": "dismiss"}})
- +def test_handle_prompt_dismiss(new_session, overwrite_capabilites):
- + _, session = new_session(overwrite_capabilites({"alwaysMatch": {"unhandledPromptBehavior": "dismiss"}}))
- session.url = inline("<body><p>Hello, World!</p></body>")
- create_dialog(session)("alert", text="dismiss #1", result_var="dismiss1")
- @@ -87,8 +87,8 @@ def test_handle_prompt_dismiss(new_session):
- # [...]
- #
- # 3. Return success.
- -def test_handle_prompt_accept(new_session):
- - _, session = new_session({"alwaysMatch": {"unhandledPromptBehavior": "accept"}})
- +def test_handle_prompt_accept(new_session, overwrite_capabilites):
- + _, session = new_session(overwrite_capabilites({"alwaysMatch": {"unhandledPromptBehavior": "accept"}}))
- session.url = inline("<body><p>Hello, World!</p></body>")
- create_dialog(session)("alert", text="accept #1", result_var="accept1")
- diff --git a/WebDriverTests/imported/w3c/webdriver/tests/fullscreen_window.py b/WebDriverTests/imported/w3c/webdriver/tests/fullscreen_window.py
- index 696c579c266..f4b66a691e1 100644
- --- a/WebDriverTests/imported/w3c/webdriver/tests/fullscreen_window.py
- +++ b/WebDriverTests/imported/w3c/webdriver/tests/fullscreen_window.py
- @@ -43,7 +43,7 @@ def test_handle_prompt_ignore():
- """TODO"""
- -def test_handle_prompt_accept(new_session):
- +def test_handle_prompt_accept(new_session, overwrite_capabilites):
- """
- 2. Handle any user prompts and return its value if it is an error.
- @@ -63,7 +63,7 @@ def test_handle_prompt_accept(new_session):
- Accept the current user prompt.
- """
- - _, session = new_session({"alwaysMatch": {"unhandledPromptBehavior": "accept"}})
- + _, session = new_session(overwrite_capabilites({"alwaysMatch": {"unhandledPromptBehavior": "accept"}}))
- session.url = inline("<title>WD doc title</title>")
- create_dialog(session)("alert", text="accept #1", result_var="accept1")
- diff --git a/WebDriverTests/imported/w3c/webdriver/tests/get_window_rect.py b/WebDriverTests/imported/w3c/webdriver/tests/get_window_rect.py
- index 3ec8ce71d47..a0f4f383617 100644
- --- a/WebDriverTests/imported/w3c/webdriver/tests/get_window_rect.py
- +++ b/WebDriverTests/imported/w3c/webdriver/tests/get_window_rect.py
- @@ -37,7 +37,7 @@ def test_handle_prompt_ignore():
- """TODO"""
- -def test_handle_prompt_accept(new_session):
- +def test_handle_prompt_accept(new_session, overwrite_capabilites):
- """
- 2. Handle any user prompts and return its value if it is an error.
- @@ -57,7 +57,7 @@ def test_handle_prompt_accept(new_session):
- Accept the current user prompt.
- """
- - _, session = new_session({"alwaysMatch": {"unhandledPromptBehavior": "accept"}})
- + _, session = new_session(overwrite_capabilites({"alwaysMatch": {"unhandledPromptBehavior": "accept"}}))
- session.url = inline("<title>WD doc title</title>")
- create_dialog(session)("alert", text="dismiss #1", result_var="dismiss1")
- diff --git a/WebDriverTests/imported/w3c/webdriver/tests/minimize_window.py b/WebDriverTests/imported/w3c/webdriver/tests/minimize_window.py
- index 497d967d982..b1428bae1c8 100644
- --- a/WebDriverTests/imported/w3c/webdriver/tests/minimize_window.py
- +++ b/WebDriverTests/imported/w3c/webdriver/tests/minimize_window.py
- @@ -37,7 +37,7 @@ def test_handle_prompt_ignore():
- """TODO"""
- -def test_handle_prompt_accept(new_session):
- +def test_handle_prompt_accept(new_session, overwrite_capabilites):
- """
- 2. Handle any user prompts and return its value if it is an error.
- @@ -57,7 +57,7 @@ def test_handle_prompt_accept(new_session):
- Accept the current user prompt.
- """
- - _, session = new_session({"alwaysMatch": {"unhandledPromptBehavior": "accept"}})
- + _, session = new_session(overwrite_capabilites({"alwaysMatch": {"unhandledPromptBehavior": "accept"}}))
- session.url = inline("<title>WD doc title</title>")
- create_dialog(session)("alert", text="dismiss #1", result_var="dismiss1")
- diff --git a/WebDriverTests/imported/w3c/webdriver/tests/navigation/get_title.py b/WebDriverTests/imported/w3c/webdriver/tests/navigation/get_title.py
- index e0f39acebad..fa97524a158 100644
- --- a/WebDriverTests/imported/w3c/webdriver/tests/navigation/get_title.py
- +++ b/WebDriverTests/imported/w3c/webdriver/tests/navigation/get_title.py
- @@ -33,8 +33,8 @@ def test_title_from_closed_context(session, create_window):
- # [...]
- #
- # 3. Return success.
- -def test_title_handle_prompt_dismiss(new_session):
- - _, session = new_session({"alwaysMatch": {"unhandledPromptBehavior": "dismiss"}})
- +def test_title_handle_prompt_dismiss(new_session, overwrite_capabilites):
- + _, session = new_session(overwrite_capabilites({"alwaysMatch": {"unhandledPromptBehavior": "dismiss"}}))
- session.url = inline("<title>WD doc title</title>")
- expected_title = read_global(session, "document.title")
- @@ -80,8 +80,8 @@ def test_title_handle_prompt_dismiss(new_session):
- # [...]
- #
- # 3. Return success.
- -def test_title_handle_prompt_accept(new_session):
- - _, session = new_session({"alwaysMatch": {"unhandledPromptBehavior": "accept"}})
- +def test_title_handle_prompt_accept(new_session, overwrite_capabilites):
- + _, session = new_session(overwrite_capabilites({"alwaysMatch": {"unhandledPromptBehavior": "accept"}}))
- session.url = inline("<title>WD doc title</title>")
- create_dialog(session)("alert", text="accept #1", result_var="accept1")
- diff --git a/WebDriverTests/imported/w3c/webdriver/tests/sessions/new_session/create_alwaysMatch.py b/WebDriverTests/imported/w3c/webdriver/tests/sessions/new_session/create_alwaysMatch.py
- index 0128c45d4fe..1d769c1caae 100644
- --- a/WebDriverTests/imported/w3c/webdriver/tests/sessions/new_session/create_alwaysMatch.py
- +++ b/WebDriverTests/imported/w3c/webdriver/tests/sessions/new_session/create_alwaysMatch.py
- @@ -8,6 +8,6 @@ from support.create import valid_data
- @pytest.mark.parametrize("key,value", flatten(product(*item) for item in valid_data))
- -def test_valid(new_session, key, value):
- - resp = new_session({"capabilities": {"alwaysMatch": {key: value}}})
- +def test_valid(new_session, overwrite_capabilites, key, value):
- + resp = new_session(overwrite_capabilites({"alwaysMatch": {key: value}}))
- diff --git a/WebDriverTests/imported/w3c/webdriver/tests/sessions/new_session/create_firstMatch.py b/WebDriverTests/imported/w3c/webdriver/tests/sessions/new_session/create_firstMatch.py
- index f0540309108..2dc685fe880 100644
- --- a/WebDriverTests/imported/w3c/webdriver/tests/sessions/new_session/create_firstMatch.py
- +++ b/WebDriverTests/imported/w3c/webdriver/tests/sessions/new_session/create_firstMatch.py
- @@ -8,5 +8,11 @@ from support.create import valid_data
- @pytest.mark.parametrize("key,value", flatten(product(*item) for item in valid_data))
- -def test_valid(new_session, key, value):
- - resp = new_session({"capabilities": {"firstMatch": [{key: value}]}})
- +def test_valid(new_session, overwrite_capabilites, key, value):
- + capabilities = overwrite_capabilites({"firstMatch": [{key: value}]})
- + # We need to remove the capability from alwaysMatch dictionary if present.
- + try:
- + del capabilities["capabilities"]["alwaysMatch"][key]
- + except KeyError:
- + pass
- + resp = new_session(capabilities)
- diff --git a/WebDriverTests/imported/w3c/webdriver/tests/sessions/new_session/default_values.py b/WebDriverTests/imported/w3c/webdriver/tests/sessions/new_session/default_values.py
- index bfe4144f5a3..f80643c5a61 100644
- --- a/WebDriverTests/imported/w3c/webdriver/tests/sessions/new_session/default_values.py
- +++ b/WebDriverTests/imported/w3c/webdriver/tests/sessions/new_session/default_values.py
- @@ -7,15 +7,15 @@ import pytest
- from webdriver import error
- -def test_basic(new_session):
- - resp, _ = new_session({"capabilities": {}})
- +def test_basic(new_session, configuration):
- + resp, _ = new_session({"capabilities": {"alwaysMatch": configuration["capabilities"]}})
- assert set(resp.keys()) == {"sessionId", "capabilities"}
- -def test_repeat_new_session(new_session):
- - resp, _ = new_session({"capabilities": {}})
- +def test_repeat_new_session(new_session, configuration):
- + resp, _ = new_session({"capabilities": {"alwaysMatch": configuration["capabilities"]}})
- with pytest.raises(error.SessionNotCreatedException):
- - new_session({"capabilities": {}})
- + new_session({"capabilities": {"alwaysMatch": configuration["capabilities"]}})
- def test_no_capabilites(new_session):
- @@ -23,12 +23,12 @@ def test_no_capabilites(new_session):
- new_session({})
- -def test_missing_first_match(new_session):
- - resp, _ = new_session({"capabilities": {"alwaysMatch": {}}})
- +def test_missing_first_match(new_session, configuration):
- + resp, _ = new_session({"capabilities": {"alwaysMatch": configuration["capabilities"]}})
- -def test_missing_always_match(new_session):
- - resp, _ = new_session({"capabilities": {"firstMatch": [{}]}})
- +def test_missing_always_match(new_session, configuration):
- + resp, _ = new_session({"capabilities": {"firstMatch": [configuration["capabilities"]]}})
- def test_desired(new_session):
- @@ -36,13 +36,13 @@ def test_desired(new_session):
- resp, _ = new_session({"desiredCapbilities": {}})
- -def test_ignore_non_spec_fields_in_capabilities(new_session):
- - resp, _ = new_session({"capabilities": {"desiredCapbilities": {"pageLoadStrategy": "eager"}}})
- +def test_ignore_non_spec_fields_in_capabilities(new_session, overwrite_capabilites):
- + resp, _ = new_session(overwrite_capabilites({"desiredCapbilities": {"pageLoadStrategy": "eager"}}))
- assert resp["capabilities"]["pageLoadStrategy"] == "normal"
- -def test_valid_but_unmatchable_key(new_session):
- - resp, _ = new_session({"capabilities": {
- +def test_valid_but_unmatchable_key(new_session, overwrite_capabilites):
- + resp, _ = new_session(overwrite_capabilites({
- "firstMatch": [{"pageLoadStrategy": "eager", "foo:unmatchable": True},
- - {"pageLoadStrategy": "none"}]}})
- + {"pageLoadStrategy": "none"}]}))
- assert resp["capabilities"]["pageLoadStrategy"] == "none"
- diff --git a/WebDriverTests/imported/w3c/webdriver/tests/sessions/new_session/invalid_capabilities.py b/WebDriverTests/imported/w3c/webdriver/tests/sessions/new_session/invalid_capabilities.py
- index 325c9b281af..d77cb85fbfd 100644
- --- a/WebDriverTests/imported/w3c/webdriver/tests/sessions/new_session/invalid_capabilities.py
- +++ b/WebDriverTests/imported/w3c/webdriver/tests/sessions/new_session/invalid_capabilities.py
- @@ -13,15 +13,15 @@ def test_invalid_capabilites(new_session, value):
- @pytest.mark.parametrize("value", [None, 1, "{}", []])
- -def test_invalid_always_match(new_session, value):
- +def test_invalid_always_match(new_session, configuration, value):
- with pytest.raises(error.InvalidArgumentException):
- - new_session({"capabilities": {"alwaysMatch": value}})
- + new_session({"capabilities": {"alwaysMatch": value, "firstMatch": [configuration["capabilities"]]}})
- @pytest.mark.parametrize("value", [None, 1, "[]", {}])
- -def test_invalid_first_match(new_session, value):
- +def test_invalid_first_match(new_session, configuration, value):
- with pytest.raises(error.InvalidArgumentException):
- - new_session({"capabilities": {"firstMatch": value}})
- + new_session({"capabilities": {"alwaysMatch": configuration["capabilities"], "firstMatch": value}})
- invalid_data = [
- @@ -49,9 +49,16 @@ invalid_data = [
- @pytest.mark.parametrize("body", [lambda key, value: {"alwaysMatch": {key: value}},
- lambda key, value: {"firstMatch": [{key: value}]}])
- @pytest.mark.parametrize("key,value", flatten(product(*item) for item in invalid_data))
- -def test_invalid(new_session, body, key, value):
- +def test_invalid_values(new_session, overwrite_capabilites, body, key, value):
- + test_capabilities = body(key, value)
- + capabilities = overwrite_capabilites(test_capabilities)
- + if "firstMatch" in test_capabilities:
- + try:
- + del capabilities["capabilities"]["alwaysMatch"][key]
- + except KeyError:
- + pass
- with pytest.raises(error.InvalidArgumentException):
- - resp = new_session({"capabilities": body(key, value)})
- + resp = new_session(capabilities)
- invalid_extensions = [
- @@ -82,7 +89,7 @@ invalid_extensions = [
- @pytest.mark.parametrize("body", [lambda key, value: {"alwaysMatch": {key: value}},
- lambda key, value: {"firstMatch": [{key: value}]}])
- @pytest.mark.parametrize("key", invalid_extensions)
- -def test_invalid(new_session, body, key):
- +def test_invalid_extensions(new_session, overwrite_capabilites, body, key):
- with pytest.raises(error.InvalidArgumentException):
- - resp = new_session({"capabilities": body(key, {})})
- + resp = new_session(overwrite_capabilites(body(key, {})))
- diff --git a/WebDriverTests/imported/w3c/webdriver/tests/sessions/new_session/merge.py b/WebDriverTests/imported/w3c/webdriver/tests/sessions/new_session/merge.py
- index 2e64620455c..c12698eb4b0 100644
- --- a/WebDriverTests/imported/w3c/webdriver/tests/sessions/new_session/merge.py
- +++ b/WebDriverTests/imported/w3c/webdriver/tests/sessions/new_session/merge.py
- @@ -9,8 +9,8 @@ from conftest import platform_name
- @pytest.mark.skipif(platform_name() is None, reason="Unsupported platform")
- @pytest.mark.parametrize("body", [lambda key, value: {"alwaysMatch": {key: value}},
- lambda key, value: {"firstMatch": [{key: value}]}])
- -def test_platform_name(new_session, platform_name, body):
- - resp, _ = new_session({"capabilities": body("platformName", platform_name)})
- +def test_platform_name(new_session, overwrite_capabilites, platform_name, body):
- + resp, _ = new_session(overwrite_capabilites(body("platformName", platform_name)))
- assert resp["capabilities"]["platformName"] == platform_name
- @@ -24,18 +24,20 @@ invalid_merge = [
- @pytest.mark.parametrize("key,value", invalid_merge)
- -def test_merge_invalid(new_session, key, value):
- +def test_merge_invalid(new_session, overwrite_capabilites, key, value):
- with pytest.raises(error.InvalidArgumentException):
- - new_session({"capabilities":
- + new_session(overwrite_capabilites(
- {"alwaysMatch": {key: value[0]},
- - "firstMatch": [{}, {key: value[1]}]}})
- + "firstMatch": [{}, {key: value[1]}]}))
- @pytest.mark.skipif(platform_name() is None, reason="Unsupported platform")
- -def test_merge_platformName(new_session, platform_name):
- +def test_merge_platformName(new_session, configuration, platform_name):
- + always_match = configuration["capabilities"]
- + always_match["timeouts"] = {"script": 10}
- resp, _ = new_session({"capabilities":
- - {"alwaysMatch": {"timeouts": {"script": 10}}},
- - "firstMatch": [
- + {"alwaysMatch": always_match,
- + "firstMatch": [
- {
- "platformName": platform_name.upper(),
- "pageLoadStrategy": "none"
- @@ -44,14 +46,16 @@ def test_merge_platformName(new_session, platform_name):
- "platformName": platform_name,
- "pageLoadStrategy": "eager"
- }
- - ]})
- + ]}})
- assert resp["capabilities"]["platformName"] == platform_name
- assert resp["capabilities"]["pageLoadStrategy"] == "eager"
- -def test_merge_browserName(new_session):
- - resp, session = new_session({})
- +def test_merge_browserName(new_session, configuration):
- + always_match = configuration["capabilities"]
- + always_match = always_match.fromkeys([k for k in always_match.keys() if k not in ["browserName", "browserVersion", "platformName"]])
- + resp, session = new_session({"capabilities": {"alwaysMatch": always_match}})
- browser_settings = {
- "browserName": resp["capabilities"]["browserName"],
- "browserVersion": resp["capabilities"]["browserVersion"],
- @@ -59,9 +63,10 @@ def test_merge_browserName(new_session):
- }
- session.end()
- + always_match["timeouts"] = {"script": 10}
- resp, _ = new_session({"capabilities":
- - {"alwaysMatch": {"timeouts": {"script": 10}}},
- - "firstMatch": [
- + {"alwaysMatch": always_match,
- + "firstMatch": [
- {
- "browserName": browser_settings["browserName"] + "invalid",
- "pageLoadStrategy": "none"
- @@ -70,7 +75,7 @@ def test_merge_browserName(new_session):
- "browserName": browser_settings["browserName"],
- "pageLoadStrategy": "eager"
- }
- - ]})
- + ]}})
- assert resp["capabilities"]["browserName"] == browser_settings['browserName']
- assert resp["capabilities"]["pageLoadStrategy"] == "eager"
- diff --git a/WebDriverTests/imported/w3c/webdriver/tests/sessions/new_session/response.py b/WebDriverTests/imported/w3c/webdriver/tests/sessions/new_session/response.py
- index 6669573ba2c..e0b49ceba12 100644
- --- a/WebDriverTests/imported/w3c/webdriver/tests/sessions/new_session/response.py
- +++ b/WebDriverTests/imported/w3c/webdriver/tests/sessions/new_session/response.py
- @@ -2,14 +2,14 @@
- import uuid
- -def test_resp_sessionid(new_session):
- - resp, _ = new_session({"capabilities": {}})
- +def test_resp_sessionid(new_session, configuration):
- + resp, _ = new_session({"capabilities": {"alwaysMatch": configuration["capabilities"]}})
- assert isinstance(resp["sessionId"], unicode)
- uuid.UUID(hex=resp["sessionId"])
- -def test_resp_capabilites(new_session):
- - resp, _ = new_session({"capabilities": {}})
- +def test_resp_capabilites(new_session, configuration):
- + resp, _ = new_session({"capabilities": {"alwaysMatch": configuration["capabilities"]}})
- assert isinstance(resp["sessionId"], unicode)
- assert isinstance(resp["capabilities"], dict)
- assert {"browserName",
- @@ -23,8 +23,8 @@ def test_resp_capabilites(new_session):
- set(resp["capabilities"].keys()))
- -def test_resp_data(new_session, platform_name):
- - resp, _ = new_session({"capabilities": {}})
- +def test_resp_data(new_session, configuration, platform_name):
- + resp, _ = new_session({"capabilities": {"alwaysMatch": configuration["capabilities"]}})
- assert isinstance(resp["capabilities"]["browserName"], unicode)
- assert isinstance(resp["capabilities"]["browserVersion"], unicode)
- @@ -41,14 +41,14 @@ def test_resp_data(new_session, platform_name):
- assert resp["capabilities"]["pageLoadStrategy"] == "normal"
- -def test_timeouts(new_session, platform_name):
- - resp, _ = new_session({"capabilities": {"alwaysMatch": {"timeouts": {"implicit": 1000}}}})
- +def test_timeouts(new_session, overwrite_capabilites, platform_name):
- + resp, _ = new_session(overwrite_capabilites({"alwaysMatch": {"timeouts": {"implicit": 1000}}}))
- assert resp["capabilities"]["timeouts"] == {
- "implicit": 1000,
- "pageLoad": 300000,
- "script": 30000
- }
- -def test_pageLoadStrategy(new_session, platform_name):
- - resp, _ = new_session({"capabilities": {"alwaysMatch": {"pageLoadStrategy": "eager"}}})
- +def test_pageLoadStrategy(new_session, overwrite_capabilites, platform_name):
- + resp, _ = new_session(overwrite_capabilites({"alwaysMatch": {"pageLoadStrategy": "eager"}}))
- assert resp["capabilities"]["pageLoadStrategy"] == "eager"
- diff --git a/WebDriverTests/imported/w3c/webdriver/tests/set_window_rect.py b/WebDriverTests/imported/w3c/webdriver/tests/set_window_rect.py
- index b300d09d111..6b39e9e5b48 100644
- --- a/WebDriverTests/imported/w3c/webdriver/tests/set_window_rect.py
- +++ b/WebDriverTests/imported/w3c/webdriver/tests/set_window_rect.py
- @@ -33,7 +33,7 @@ def test_handle_prompt_dismiss():
- """TODO"""
- -def test_handle_prompt_accept(new_session):
- +def test_handle_prompt_accept(new_session, overwrite_capabilites):
- """
- 2. Handle any user prompts and return its value if it is an error.
- @@ -53,8 +53,7 @@ def test_handle_prompt_accept(new_session):
- Accept the current user prompt.
- """
- - _, session = new_session(
- - {"alwaysMatch": {"unhandledPromptBehavior": "accept"}})
- + _, session = new_session(overwrite_capabilites({"alwaysMatch": {"unhandledPromptBehavior": "accept"}}))
- original = session.window.rect
- # step 2
- diff --git a/WebDriverTests/imported/w3c/webdriver/tests/state/get_element_attribute.py b/WebDriverTests/imported/w3c/webdriver/tests/state/get_element_attribute.py
- index e662d95a9c7..8c718d5aee1 100644
- --- a/WebDriverTests/imported/w3c/webdriver/tests/state/get_element_attribute.py
- +++ b/WebDriverTests/imported/w3c/webdriver/tests/state/get_element_attribute.py
- @@ -24,9 +24,9 @@ def test_no_browsing_context(session, create_window):
- assert_error(result, "no such window")
- -def test_handle_prompt_dismiss(new_session):
- +def test_handle_prompt_dismiss(new_session, overwrite_capabilites):
- # 13.2 step 2
- - _, session = new_session({"alwaysMatch": {"unhandledPromptBehavior": "dismiss"}})
- + _, session = new_session(overwrite_capabilites({"alwaysMatch": {"unhandledPromptBehavior": "dismiss"}}))
- session.url = inline("<input id=foo>")
- create_dialog(session)("alert", text="dismiss #1", result_var="dismiss1")
- @@ -51,9 +51,9 @@ def test_handle_prompt_dismiss(new_session):
- assert_dialog_handled(session, "dismiss #3")
- -def test_handle_prompt_accept(new_session):
- +def test_handle_prompt_accept(new_session, overwrite_capabilites):
- # 13.2 step 2
- - _, session = new_session({"alwaysMatch": {"unhandledPromptBehavior": "accept"}})
- + _, session = new_session(overwrite_capabilites({"alwaysMatch": {"unhandledPromptBehavior": "accept"}}))
- session.url = inline("<input id=foo>")
- create_dialog(session)("alert", text="dismiss #1", result_var="dismiss1")
- diff --git a/WebDriverTests/imported/w3c/webdriver/tests/state/get_element_property.py b/WebDriverTests/imported/w3c/webdriver/tests/state/get_element_property.py
- index 00a85af69b5..cc33d005810 100644
- --- a/WebDriverTests/imported/w3c/webdriver/tests/state/get_element_property.py
- +++ b/WebDriverTests/imported/w3c/webdriver/tests/state/get_element_property.py
- @@ -19,9 +19,9 @@ def test_no_browsing_context(session, create_window):
- assert_error(result, "no such window")
- -def test_handle_prompt_dismiss(new_session):
- +def test_handle_prompt_dismiss(new_session, overwrite_capabilites):
- # 13.3 step 2
- - _, session = new_session({"alwaysMatch": {"unhandledPromptBehavior": "dismiss"}})
- + _, session = new_session(overwrite_capabilites({"alwaysMatch": {"unhandledPromptBehavior": "dismiss"}}))
- session.url = inline("<input id=foo>")
- create_dialog(session)("alert", text="dismiss #1", result_var="dismiss1")
- @@ -53,9 +53,9 @@ def test_handle_prompt_dismiss(new_session):
- -def test_handle_prompt_accept(new_session):
- +def test_handle_prompt_accept(new_session, overwrite_capabilites):
- # 13.3 step 2
- - _, session = new_session({"alwaysMatch": {"unhandledPromptBehavior": "accept"}})
- + _, session = new_session(overwrite_capabilites({"alwaysMatch": {"unhandledPromptBehavior": "accept"}}))
- session.url = inline("<input id=foo>")
- create_dialog(session)("alert", text="dismiss #1", result_var="dismiss1")
- diff --git a/WebDriverTests/imported/w3c/webdriver/tests/state/get_element_tag_name.py b/WebDriverTests/imported/w3c/webdriver/tests/state/get_element_tag_name.py
- index 4100e9b1e17..05b03d93310 100644
- --- a/WebDriverTests/imported/w3c/webdriver/tests/state/get_element_tag_name.py
- +++ b/WebDriverTests/imported/w3c/webdriver/tests/state/get_element_tag_name.py
- @@ -17,9 +17,9 @@ def test_no_browsing_context(session, create_window):
- assert_error(result, "no such window")
- -def test_handle_prompt_dismiss(new_session):
- +def test_handle_prompt_dismiss(new_session, overwrite_capabilites):
- # 13.6 step 2
- - _, session = new_session({"alwaysMatch": {"unhandledPromptBehavior": "dismiss"}})
- + _, session = new_session(overwrite_capabilites({"alwaysMatch": {"unhandledPromptBehavior": "dismiss"}}))
- session.url = inline("<input id=foo>")
- create_dialog(session)("alert", text="dismiss #1", result_var="dismiss1")
- @@ -50,9 +50,9 @@ def test_handle_prompt_dismiss(new_session):
- assert_dialog_handled(session, "dismiss #3")
- -def test_handle_prompt_accept(new_session):
- +def test_handle_prompt_accept(new_session, overwrite_capabilites):
- # 13.6 step 2
- - _, session = new_session({"alwaysMatch": {"unhandledPromptBehavior": "accept"}})
- + _, session = new_session(overwrite_capabilites({"alwaysMatch": {"unhandledPromptBehavior": "accept"}}))
- session.url = inline("<input id=foo>")
- create_dialog(session)("alert", text="dismiss #1", result_var="dismiss1")
- diff --git a/WebDriverTests/imported/w3c/webdriver/tests/state/is_element_selected.py b/WebDriverTests/imported/w3c/webdriver/tests/state/is_element_selected.py
- index c82f26fa912..c7411f6a337 100644
- --- a/WebDriverTests/imported/w3c/webdriver/tests/state/is_element_selected.py
- +++ b/WebDriverTests/imported/w3c/webdriver/tests/state/is_element_selected.py
- @@ -26,9 +26,9 @@ def test_no_browsing_context(session, create_window):
- assert_error(result, "no such window")
- -def test_handle_prompt_dismiss(new_session):
- +def test_handle_prompt_dismiss(new_session, overwrite_capabilites):
- # 13.1 step 2
- - _, session = new_session({"alwaysMatch": {"unhandledPromptBehavior": "dismiss"}})
- + _, session = new_session(overwrite_capabilites({"alwaysMatch": {"unhandledPromptBehavior": "dismiss"}}))
- session.url = inline("<input id=foo>")
- create_dialog(session)("alert", text="dismiss #1", result_var="dismiss1")
- @@ -59,9 +59,9 @@ def test_handle_prompt_dismiss(new_session):
- assert_dialog_handled(session, "dismiss #3")
- -def test_handle_prompt_accept(new_session):
- +def test_handle_prompt_accept(new_session, overwrite_capabilites):
- # 13.1 step 2
- - _, session = new_session({"alwaysMatch": {"unhandledPromptBehavior": "accept"}})
- + _, session = new_session(overwrite_capabilites({"alwaysMatch": {"unhandledPromptBehavior": "accept"}}))
- session.url = inline("<input id=foo>")
- create_dialog(session)("alert", text="dismiss #1", result_var="dismiss1")
- diff --git a/WebDriverTests/imported/w3c/webdriver/tests/support/__init__.py b/WebDriverTests/imported/w3c/webdriver/tests/support/__init__.py
- index d37faf6da04..305bb29f8bf 100644
- --- a/WebDriverTests/imported/w3c/webdriver/tests/support/__init__.py
- +++ b/WebDriverTests/imported/w3c/webdriver/tests/support/__init__.py
- @@ -1 +1 @@
- -from merge_dictionaries import merge_dictionaries
- +from merge_dictionaries import merge_dictionaries, overwrite_dictionary
- diff --git a/WebDriverTests/imported/w3c/webdriver/tests/support/fixtures.py b/WebDriverTests/imported/w3c/webdriver/tests/support/fixtures.py
- index d93f862578a..bd4fc3fec9b 100644
- --- a/WebDriverTests/imported/w3c/webdriver/tests/support/fixtures.py
- +++ b/WebDriverTests/imported/w3c/webdriver/tests/support/fixtures.py
- @@ -8,7 +8,7 @@ import mozlog
- from tests.support.asserts import assert_error
- from tests.support.http_request import HTTPRequest
- -from tests.support import merge_dictionaries
- +from tests.support import merge_dictionaries, overwrite_dictionary
- default_host = "http://127.0.0.1"
- default_port = "4444"
- @@ -188,8 +188,6 @@ def new_session(configuration, request):
- _session = webdriver.Session(configuration["host"],
- configuration["port"],
- capabilities=None)
- - # TODO: merge in some capabilities from the confguration capabilities
- - # since these might be needed to start the browser
- value = _session.send_command("POST", "session", body=body)
- # Don't set the global session until we are sure this succeeded
- _current_session = _session
- @@ -203,6 +201,12 @@ def new_session(configuration, request):
- return create_session
- +def overwrite_capabilites(configuration):
- + def create_capabilities(capabilities):
- + return {"capabilities": overwrite_dictionary({"alwaysMatch": configuration["capabilities"]}, capabilities)}
- + return create_capabilities
- +
- +
- def url(server_config):
- def inner(path, protocol="http", query="", fragment=""):
- port = server_config["ports"][protocol][0]
- diff --git a/WebDriverTests/imported/w3c/webdriver/tests/support/merge_dictionaries.py b/WebDriverTests/imported/w3c/webdriver/tests/support/merge_dictionaries.py
- index cf06c9b433c..c221af3514d 100644
- --- a/WebDriverTests/imported/w3c/webdriver/tests/support/merge_dictionaries.py
- +++ b/WebDriverTests/imported/w3c/webdriver/tests/support/merge_dictionaries.py
- @@ -24,6 +24,27 @@ def merge_dictionaries(first, second):
- return result
- +def overwrite_dictionary(first, second):
- + """Given two dictionaries, create a third that defines all specified
- + key/value pairs. This merge_dictionaries is performed "deeply" on any nested
- + dictionaries. If a value is defined for the same key by both dictionaries,
- + the vale of the second one is used."""
- + result = dict(first)
- +
- + for key, value in iteritems(first):
- + if key not in second or second[key] == value:
- + continue
- + if isinstance(second[key], dict) and isinstance(value, dict):
- + result[key] = overwrite_dictionary(result[key], second[key])
- + else:
- + result[key] = second[key]
- +
- + for key, value in iteritems(second):
- + if key not in result:
- + result[key] = value
- +
- + return result
- +
- if __name__ == "__main__":
- assert merge_dictionaries({}, {}) == {}
- assert merge_dictionaries({}, {"a": 23}) == {"a": 23}
- @@ -47,3 +68,12 @@ if __name__ == "__main__":
- except Exception as _e:
- e = _e
- assert isinstance(e, TypeError)
- +
- + assert overwrite_dictionary({}, {}) == {}
- + assert overwrite_dictionary({}, {"a": 23}) == {"a": 23}
- + assert overwrite_dictionary({"a": 23}, {}) == {"a": 23}
- + assert overwrite_dictionary({"a": 23}, {"b": 45}) == {"a": 23, "b": 45}
- +
- + assert overwrite_dictionary({"a": 23, "b": 45}, {"b": 55}) == {"a": 23, "b": 55}
- + assert overwrite_dictionary({"a": {"b": 23, "d": 60}}, {"a": {"b": 45, "c": 55}}) == {"a": {"b": 45, "c": 55, "d": 60}}
- + assert overwrite_dictionary({"a": {"b": 23, "d": 60}}, {"a": {"b": 23, "d": 65, "f": {"g": 75}}, "z": -10}) == {"a": {"b": 23, "d": 65, "f": {"g": 75}}, "z": -10}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement