Bug 1455568 - [wdspec] Use a shared custom command for all tests in a module. draft
authorHenrik Skupin <mail@hskupin.info>
Tue, 24 Apr 2018 18:57:48 +0200
changeset 789755 ca0e01ba92eaf712fffb8afb0941615c73cb2e73
parent 789754 ba2afc256d21c1a0df96d3b8cc4a2b4c59cc7d2e
child 789756 be7a25f77ae1398e29e886e377200744bc93dae5
push id108337
push userbmo:hskupin@gmail.com
push dateMon, 30 Apr 2018 15:15:02 +0000
bugs1455568
milestone61.0a1
Bug 1455568 - [wdspec] Use a shared custom command for all tests in a module. MozReview-Commit-ID: 11lAp7J8IoZ
testing/web-platform/tests/webdriver/tests/add_cookie/__init__.py
testing/web-platform/tests/webdriver/tests/add_cookie/add.py
testing/web-platform/tests/webdriver/tests/add_cookie/conftest.py
testing/web-platform/tests/webdriver/tests/delete_cookie/delete.py
testing/web-platform/tests/webdriver/tests/element_clear/clear.py
testing/web-platform/tests/webdriver/tests/element_click/bubbling.py
testing/web-platform/tests/webdriver/tests/element_click/stale.py
testing/web-platform/tests/webdriver/tests/element_send_keys/form_controls.py
testing/web-platform/tests/webdriver/tests/element_send_keys/interactability.py
testing/web-platform/tests/webdriver/tests/element_send_keys/scroll_into_view.py
testing/web-platform/tests/webdriver/tests/execute_async_script/collections.py
testing/web-platform/tests/webdriver/tests/execute_script/collections.py
testing/web-platform/tests/webdriver/tests/execute_script/cyclic.py
testing/web-platform/tests/webdriver/tests/find_element/find.py
testing/web-platform/tests/webdriver/tests/find_element_from_element/find.py
testing/web-platform/tests/webdriver/tests/find_elements/find.py
testing/web-platform/tests/webdriver/tests/find_elements_from_element/find.py
testing/web-platform/tests/webdriver/tests/fullscreen_window/fullscreen.py
testing/web-platform/tests/webdriver/tests/get_active_element/get.py
testing/web-platform/tests/webdriver/tests/get_current_url/get.py
testing/web-platform/tests/webdriver/tests/get_element_attribute/get.py
testing/web-platform/tests/webdriver/tests/get_element_property/get.py
testing/web-platform/tests/webdriver/tests/get_element_tag_name/get.py
testing/web-platform/tests/webdriver/tests/get_element_text/get.py
testing/web-platform/tests/webdriver/tests/get_named_cookie/get.py
testing/web-platform/tests/webdriver/tests/get_timeouts/get.py
testing/web-platform/tests/webdriver/tests/get_title/__init__.py
testing/web-platform/tests/webdriver/tests/get_title/conftest.py
testing/web-platform/tests/webdriver/tests/get_title/get.py
testing/web-platform/tests/webdriver/tests/get_window_rect/get.py
testing/web-platform/tests/webdriver/tests/is_element_selected/selected.py
testing/web-platform/tests/webdriver/tests/maximize_window/maximize.py
testing/web-platform/tests/webdriver/tests/set_window_rect/set.py
testing/web-platform/tests/webdriver/tests/switch_to_parent_frame/switch.py
testing/web-platform/tests/webdriver/tests/user_prompts/accept_alert.py
testing/web-platform/tests/webdriver/tests/user_prompts/dismiss_alert.py
testing/web-platform/tests/webdriver/tests/user_prompts/get_alert_text.py
testing/web-platform/tests/webdriver/tests/user_prompts/send_alert_text.py
new file mode 100644
--- a/testing/web-platform/tests/webdriver/tests/add_cookie/add.py
+++ b/testing/web-platform/tests/webdriver/tests/add_cookie/add.py
@@ -1,25 +1,27 @@
 from tests.support.fixtures import clear_all_cookies
 from datetime import datetime, timedelta
 
-def test_add_domain_cookie(session, url, server_config):
+
+def test_add_domain_cookie(session, url, server_config, add_cookie):
     session.url = url("/common/blank.html")
     clear_all_cookies(session)
-    create_cookie_request = {
+    new_cookie = {
         "cookie": {
             "name": "hello",
             "value": "world",
             "domain": server_config["domains"][""],
             "path": "/",
             "httpOnly": False,
             "secure": False
         }
     }
-    result = session.transport.send("POST", "session/%s/cookie" % session.session_id, create_cookie_request)
+
+    result = add_cookie(new_cookie)
     assert result.status == 200
     assert "value" in result.body
     assert result.body["value"] is None
 
     result = session.transport.send("GET", "session/%s/cookie" % session.session_id)
     assert result.status == 200
     assert "value" in result.body
     assert isinstance(result.body["value"], list)
@@ -33,31 +35,32 @@ def test_add_domain_cookie(session, url,
     assert isinstance(cookie["value"], basestring)
     assert "domain" in cookie
     assert isinstance(cookie["domain"], basestring)
 
     assert cookie["name"] == "hello"
     assert cookie["value"] == "world"
     assert cookie["domain"] == ".%s" % server_config["domains"][""] or cookie["domain"] == "%s" % server_config["domains"][""]
 
-def test_add_cookie_for_ip(session, url, server_config, configuration):
+
+def test_add_cookie_for_ip(session, url, server_config, configuration, add_cookie):
     session.url = "http://127.0.0.1:%s/common/blank.html" % (server_config["ports"]["http"][0])
     clear_all_cookies(session)
-    create_cookie_request = {
+    new_cookie = {
         "cookie": {
             "name": "hello",
             "value": "world",
             "domain": "127.0.0.1",
             "path": "/",
             "httpOnly": False,
             "secure": False
         }
     }
 
-    result = session.transport.send("POST", "session/%s/cookie" % session.session_id, create_cookie_request)
+    result = add_cookie(new_cookie)
     assert result.status == 200
     assert "value" in result.body
     assert result.body["value"] is None
 
     result = session.transport.send("GET", "session/%s/cookie" % session.session_id)
     assert result.status == 200
     assert "value" in result.body
     assert isinstance(result.body["value"], list)
@@ -71,28 +74,30 @@ def test_add_cookie_for_ip(session, url,
     assert isinstance(cookie["value"], basestring)
     assert "domain" in cookie
     assert isinstance(cookie["domain"], basestring)
 
     assert cookie["name"] == "hello"
     assert cookie["value"] == "world"
     assert cookie["domain"] == "127.0.0.1"
 
-def test_add_non_session_cookie(session, url):
+
+def test_add_non_session_cookie(session, url, add_cookie):
     session.url = url("/common/blank.html")
     clear_all_cookies(session)
     a_year_from_now = int((datetime.utcnow() + timedelta(days=365) - datetime.utcfromtimestamp(0)).total_seconds())
-    create_cookie_request = {
+    new_cookie = {
         "cookie": {
             "name": "hello",
             "value": "world",
             "expiry": a_year_from_now
         }
     }
-    result = session.transport.send("POST", "session/%s/cookie" % session.session_id, create_cookie_request)
+
+    result = add_cookie(new_cookie)
     assert result.status == 200
     assert "value" in result.body
     assert result.body["value"] is None
 
     result = session.transport.send("GET", "session/%s/cookie" % session.session_id)
     assert result.status == 200
     assert "value" in result.body
     assert isinstance(result.body["value"], list)
@@ -106,26 +111,28 @@ def test_add_non_session_cookie(session,
     assert isinstance(cookie["value"], basestring)
     assert "expiry" in cookie
     assert isinstance(cookie["expiry"], int)
 
     assert cookie["name"] == "hello"
     assert cookie["value"] == "world"
     assert cookie["expiry"] == a_year_from_now
 
-def test_add_session_cookie(session, url):
+
+def test_add_session_cookie(session, url, add_cookie):
     session.url = url("/common/blank.html")
     clear_all_cookies(session)
-    create_cookie_request = {
+    new_cookie = {
         "cookie": {
             "name": "hello",
             "value": "world"
         }
     }
-    result = session.transport.send("POST", "session/%s/cookie" % session.session_id, create_cookie_request)
+
+    result = add_cookie(new_cookie)
     assert result.status == 200
     assert "value" in result.body
     assert result.body["value"] is None
 
     result = session.transport.send("GET", "session/%s/cookie" % session.session_id)
     assert result.status == 200
     assert "value" in result.body
     assert isinstance(result.body["value"], list)
@@ -138,27 +145,30 @@ def test_add_session_cookie(session, url
     assert "value" in cookie
     assert isinstance(cookie["value"], basestring)
     if "expiry" in cookie:
         assert cookie.get("expiry") is None
 
     assert cookie["name"] == "hello"
     assert cookie["value"] == "world"
 
-def test_add_session_cookie_with_leading_dot_character_in_domain(session, url, server_config):
+
+def test_add_session_cookie_with_leading_dot_character_in_domain(
+        session, url, server_config, add_cookie):
     session.url = url("/common/blank.html")
     clear_all_cookies(session)
-    create_cookie_request = {
+    new_cookie = {
         "cookie": {
             "name": "hello",
             "value": "world",
             "domain": ".%s" % server_config["domains"][""]
         }
     }
-    result = session.transport.send("POST", "session/%s/cookie" % session.session_id, create_cookie_request)
+
+    result = add_cookie(new_cookie)
     assert result.status == 200
     assert "value" in result.body
     assert result.body["value"] is None
 
     result = session.transport.send("GET", "session/%s/cookie" % session.session_id)
     assert result.status == 200
     assert "value" in result.body
     assert isinstance(result.body["value"], list)
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/webdriver/tests/add_cookie/conftest.py
@@ -0,0 +1,11 @@
+import pytest
+
+
+@pytest.fixture
+def add_cookie(session):
+    def _add_cookie(cookie):
+        return session.transport.send(
+            "POST", "session/{session_id}/cookie".format(**vars(session)),
+            cookie)
+
+    return _add_cookie
--- a/testing/web-platform/tests/webdriver/tests/delete_cookie/delete.py
+++ b/testing/web-platform/tests/webdriver/tests/delete_cookie/delete.py
@@ -1,15 +1,17 @@
 from tests.support.asserts import assert_error, assert_dialog_handled, assert_success
 from tests.support.fixtures import create_dialog
 from tests.support.inline import inline
 
 
 def delete_cookie(session, name):
-    return session.transport.send("DELETE", "/session/%s/cookie/%s" % (session.session_id, name))
+    return session.transport.send(
+        "DELETE", "/session/{session_id}/cookie/{name}".format(
+            session_id=session.session_id, name=name))
 
 
 # 16.4 Delete Cookie
 
 
 def test_no_browsing_context(session, create_window):
     """
     1. If the current top-level browsing context is no longer open,
--- a/testing/web-platform/tests/webdriver/tests/element_clear/clear.py
+++ b/testing/web-platform/tests/webdriver/tests/element_clear/clear.py
@@ -27,18 +27,20 @@ def get_events(session):
 @pytest.fixture(scope="session")
 def text_file(tmpdir_factory):
     fh = tmpdir_factory.mktemp("tmp").join("hello.txt")
     fh.write("hello")
     return fh
 
 
 def element_clear(session, element):
-    return session.transport.send("POST", "/session/%s/element/%s/clear" %
-                                  (session.session_id, element.id))
+    return session.transport.send(
+        "POST", "/session/{session_id}/element/{element_id}/clear".format(
+            session_id=session.session_id,
+            element_id=element.id))
 
 
 def test_closed_context(session, create_window):
     new_window = create_window()
     session.window_handle = new_window
     session.url = inline("<input>")
     element = session.find.css("input", all=False)
     session.close()
--- a/testing/web-platform/tests/webdriver/tests/element_click/bubbling.py
+++ b/testing/web-platform/tests/webdriver/tests/element_click/bubbling.py
@@ -1,12 +1,12 @@
 from tests.support.asserts import assert_success
 from tests.support.inline import inline
 
-def click(session, element):
+def click_element(session, element):
     return session.transport.send(
         "POST", "/session/{session_id}/element/{element_id}/click".format(
             session_id=session.session_id,
             element_id=element.id))
 
 
 def test_click_event_bubbles_to_parents(session):
     session.url = inline("""
@@ -145,10 +145,10 @@ def test_element_disappears_during_click
         }
 
         over.addEventListener("mousedown", () => over.style.display = "none");
         </script>
         """)
     over = session.find.css("#over", all=False)
 
     # should not time out
-    response = click(session, over)
+    response = click_element(session, over)
     assert_success(response)
--- a/testing/web-platform/tests/webdriver/tests/element_click/stale.py
+++ b/testing/web-platform/tests/webdriver/tests/element_click/stale.py
@@ -2,20 +2,19 @@ import pytest
 import webdriver
 
 from tests.support.asserts import assert_error
 from tests.support.inline import inline
 
 
 def click_element(session, element):
     return session.transport.send(
-        "POST", "/session/{session_id}/element/{element_id}/click".format(**{
+        "POST", "/session/{session_id}/element/{element_id}/click".format(
             "session_id": session.session_id,
-            "element_id": element.id,
-        }))
+            "element_id": element.id))
 
 
 def test_is_stale(session):
     session.url = inline("<button>foo</button>")
     button = session.find.css("button", all=False)
     session.url = inline("<button>bar</button>")
 
     response = click_element(session, button)
--- a/testing/web-platform/tests/webdriver/tests/element_send_keys/form_controls.py
+++ b/testing/web-platform/tests/webdriver/tests/element_send_keys/form_controls.py
@@ -4,20 +4,19 @@ from tests.support.asserts import (
     assert_element_has_focus,
     assert_error,
     assert_same_element,
     assert_success,
 )
 from tests.support.inline import inline
 
 
-def element_send_keys(session, element, text):
+def send_keys_to_element(session, element, text):
     return session.transport.send(
-        "POST",
-        "/session/{session_id}/element/{element_id}/value".format(
+        "POST", "/session/{session_id}/element/{element_id}/value".format(
             session_id=session.session_id,
             element_id=element.id),
         {"text": text})
 
 
 def add_event_listeners(element):
     element.session.execute_script("""
         window.events = [];
@@ -32,62 +31,62 @@ def get_events(session):
     return session.execute_script("return window.events")
 
 
 def test_input(session):
     session.url = inline("<input>")
     element = session.find.css("input", all=False)
     assert element.property("value") == ""
 
-    element_send_keys(session, element, "foo")
+    send_keys_to_element(session, element, "foo")
     assert element.property("value") == "foo"
     assert_element_has_focus(element)
 
 
 def test_textarea(session):
     session.url = inline("<textarea>")
     element = session.find.css("textarea", all=False)
     assert element.property("value") == ""
 
-    element_send_keys(session, element, "foo")
+    send_keys_to_element(session, element, "foo")
     assert element.property("value") == "foo"
     assert_element_has_focus(element)
 
 
 def test_input_append(session):
     session.url = inline("<input value=a>")
     element = session.find.css("input", all=False)
     assert element.property("value") == "a"
 
-    element_send_keys(session, element, "b")
+    send_keys_to_element(session, element, "b")
     assert element.property("value") == "ab"
 
-    element_send_keys(session, element, "c")
+    send_keys_to_element(session, element, "c")
     assert element.property("value") == "abc"
 
 
 def test_textarea_append(session):
     session.url = inline("<textarea>a</textarea>")
     element = session.find.css("textarea", all=False)
     assert element.property("value") == "a"
 
-    element_send_keys(session, element, "b")
+    send_keys_to_element(session, element, "b")
     assert element.property("value") == "ab"
 
-    element_send_keys(session, element, "c")
+    send_keys_to_element(session, element, "c")
     assert element.property("value") == "abc"
 
 
 @pytest.mark.parametrize("tag", ["input", "textarea"])
 def test_events(session, tag):
     session.url = inline("<%s>" % tag)
     element = session.find.css(tag, all=False)
     add_event_listeners(element)
 
-    element_send_keys(session, element, "foo")
+    send_keys_to_element(session, element, "foo")
     assert element.property("value") == "foo"
     assert get_events(session) == ["focus",
                                    "keydown",
                                    "keypress",
                                    "input",
                                    "keyup",
                                    "keydown",
                                    "keypress",
@@ -99,10 +98,10 @@ def test_events(session, tag):
                                    "keyup"]
 
 
 @pytest.mark.parametrize("tag", ["input", "textarea"])
 def test_not_blurred(session, tag):
     session.url = inline("<%s>" % tag)
     element = session.find.css(tag, all=False)
 
-    element_send_keys(session, element, "")
+    send_keys_to_element(session, element, "")
     assert_element_has_focus(element)
--- a/testing/web-platform/tests/webdriver/tests/element_send_keys/interactability.py
+++ b/testing/web-platform/tests/webdriver/tests/element_send_keys/interactability.py
@@ -1,16 +1,15 @@
 from tests.support.asserts import assert_error, assert_success
 from tests.support.inline import iframe, inline
 
 
 def send_keys_to_element(session, element, text):
     return session.transport.send(
-        "POST",
-        "/session/{session_id}/element/{element_id}/value".format(
+        "POST", "/session/{session_id}/element/{element_id}/value".format(
             session_id=session.session_id,
             element_id=element.id),
         {"text": text})
 
 
 def test_body_is_interactable(session):
     session.url = inline("""
         <body onkeypress="document.querySelector('input').value += event.key">
--- a/testing/web-platform/tests/webdriver/tests/element_send_keys/scroll_into_view.py
+++ b/testing/web-platform/tests/webdriver/tests/element_send_keys/scroll_into_view.py
@@ -1,17 +1,16 @@
 from tests.support.asserts import assert_success
 from tests.support.fixtures import is_element_in_viewport
 from tests.support.inline import inline
 
 
 def send_keys_to_element(session, element, text):
     return session.transport.send(
-        "POST",
-        "/session/{session_id}/element/{element_id}/value".format(
+        "POST", "/session/{session_id}/element/{element_id}/value".format(
             session_id=session.session_id,
             element_id=element.id),
         {"text": text})
 
 
 def test_element_outside_of_not_scrollable_viewport(session):
     session.url = inline("<input style=\"position: relative; left: -9999px;\">")
     element = session.find.css("input", all=False)
--- a/testing/web-platform/tests/webdriver/tests/execute_async_script/collections.py
+++ b/testing/web-platform/tests/webdriver/tests/execute_async_script/collections.py
@@ -4,18 +4,17 @@ from tests.support.asserts import assert
 from tests.support.inline import inline
 
 
 def execute_async_script(session, script, args=None):
     if args is None:
         args = []
     body = {"script": script, "args": args}
     return session.transport.send(
-        "POST",
-        "/session/{session_id}/execute/async".format(**vars(session)),
+        "POST", "/session/{session_id}/execute/async".format(**vars(session)),
         body)
 
 
 def test_arguments(session):
     response = execute_async_script(session, """
         let [resolve] = arguments;
         function func() {
             return arguments;
--- a/testing/web-platform/tests/webdriver/tests/execute_script/collections.py
+++ b/testing/web-platform/tests/webdriver/tests/execute_script/collections.py
@@ -4,18 +4,17 @@ from tests.support.asserts import assert
 from tests.support.inline import inline
 
 
 def execute_script(session, script, args=None):
     if args is None:
         args = []
     body = {"script": script, "args": args}
     return session.transport.send(
-        "POST",
-        "/session/{session_id}/execute/sync".format(**vars(session)),
+        "POST", "/session/{session_id}/execute/sync".format(**vars(session)),
         body)
 
 
 def test_arguments(session):
     response = execute_script(session, """
         function func() {
             return arguments;
         }
--- a/testing/web-platform/tests/webdriver/tests/execute_script/cyclic.py
+++ b/testing/web-platform/tests/webdriver/tests/execute_script/cyclic.py
@@ -1,18 +1,17 @@
 from tests.support.asserts import assert_error
 
 
 def execute_script(session, script, args=None):
     if args is None:
         args = []
     body = {"script": script, "args": args}
     return session.transport.send(
-        "POST",
-        "/session/{session_id}/execute/sync".format(
+        "POST", "/session/{session_id}/execute/sync".format(
             session_id=session.session_id),
         body)
 
 
 def test_array(session):
     response = execute_script(session, """
         let arr = [];
         arr.push(arr);
--- a/testing/web-platform/tests/webdriver/tests/find_element/find.py
+++ b/testing/web-platform/tests/webdriver/tests/find_element/find.py
@@ -1,18 +1,18 @@
 import pytest
 
 from tests.support.asserts import assert_error, assert_same_element, assert_success
 from tests.support.inline import inline
 
 
 def find_element(session, using, value):
-    return session.transport.send("POST",
-                                  "session/%s/element" % session.session_id,
-                                  {"using": using, "value": value})
+    return session.transport.send(
+        "POST", "session/{session_id}/element".format(**vars(session)),
+        {"using": using, "value": value})
 
 
 # 12.2 Find Element
 
 @pytest.mark.parametrize("using", ["a", True, None, 1, [], {}])
 def test_invalid_using_argument(session, using):
     # Step 1 - 2
     response = find_element(session, using, "value")
--- a/testing/web-platform/tests/webdriver/tests/find_element_from_element/find.py
+++ b/testing/web-platform/tests/webdriver/tests/find_element_from_element/find.py
@@ -1,18 +1,20 @@
 import pytest
 
 from tests.support.asserts import assert_error, assert_same_element, assert_success
 from tests.support.inline import inline
 
 
-def find_element(session, element, using, value):
-    return session.transport.send("POST",
-                                  "session/%s/element/%s/element" % (session.session_id, element),
-                                  {"using": using, "value": value})
+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.mark.parametrize("using", ["a", True, None, 1, [], {}])
 def test_invalid_using_argument(session, using):
     # Step 1 - 2
     response = find_element(session, "notReal", using, "value")
     assert_error(response, "invalid argument")
 
--- a/testing/web-platform/tests/webdriver/tests/find_elements/find.py
+++ b/testing/web-platform/tests/webdriver/tests/find_elements/find.py
@@ -1,18 +1,18 @@
 import pytest
 
 from tests.support.asserts import assert_error, assert_same_element, assert_success
 from tests.support.inline import inline
 
 
 def find_elements(session, using, value):
-    return session.transport.send("POST",
-                                  "session/%s/elements" % session.session_id,
-                                  {"using": using, "value": value})
+    return session.transport.send(
+        "POST", "session/{session_id}/elements".format(**vars(session)),
+        {"using": using, "value": value})
 
 
 @pytest.mark.parametrize("using", ["a", True, None, 1, [], {}])
 def test_invalid_using_argument(session, using):
     # Step 1 - 2
     response = find_elements(session, using, "value")
     assert_error(response, "invalid argument")
 
--- a/testing/web-platform/tests/webdriver/tests/find_elements_from_element/find.py
+++ b/testing/web-platform/tests/webdriver/tests/find_elements_from_element/find.py
@@ -1,18 +1,20 @@
 import pytest
 
 from tests.support.asserts import assert_error, assert_same_element, assert_success
 from tests.support.inline import inline
 
 
-def find_elements(session, element, using, value):
-    return session.transport.send("POST",
-                                  "session/%s/element/%s/elements" % (session.session_id, element),
-                                  {"using": using, "value": value})
+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.mark.parametrize("using", [("a"), (True), (None), (1), ([]), ({})])
 def test_invalid_using_argument(session, using):
     # Step 1 - 2
     response = find_elements(session, "notReal", using, "value")
     assert_error(response, "invalid argument")
 
 
--- a/testing/web-platform/tests/webdriver/tests/fullscreen_window/fullscreen.py
+++ b/testing/web-platform/tests/webdriver/tests/fullscreen_window/fullscreen.py
@@ -8,17 +8,18 @@ from tests.support.inline import inline
 alert_doc = inline("<script>window.alert()</script>")
 
 
 def read_global(session, name):
     return session.execute_script("return %s;" % name)
 
 
 def fullscreen(session):
-    return session.transport.send("POST", "session/%s/window/fullscreen" % session.session_id)
+    return session.transport.send(
+        "POST", "session/{session_id}/window/fullscreen".format(**vars(session)))
 
 
 def is_fullscreen(session):
     # At the time of writing, WebKit does not conform to the Fullscreen API specification.
     # Remove the prefixed fallback when https://bugs.webkit.org/show_bug.cgi?id=158125 is fixed.
     return session.execute_script("return !!(window.fullScreen || document.webkitIsFullScreen)")
 
 
--- a/testing/web-platform/tests/webdriver/tests/get_active_element/get.py
+++ b/testing/web-platform/tests/webdriver/tests/get_active_element/get.py
@@ -3,17 +3,18 @@ from tests.support.fixtures import creat
 from tests.support.inline import inline
 
 
 def read_global(session, name):
     return session.execute_script("return %s;" % name)
 
 
 def get_active_element(session):
-    return session.transport.send("GET", "session/%s/element/active" % session.session_id)
+    return session.transport.send(
+        "GET", "session/{session_id}/element/active".format(**vars(session)))
 
 
 def assert_is_active_element(session, response):
     """Ensure that the provided object is a successful WebDriver
     response describing an element reference and that the referenced
     element matches the element returned by the `activeElement`
     attribute of the current browsing context's active document.
 
--- a/testing/web-platform/tests/webdriver/tests/get_current_url/get.py
+++ b/testing/web-platform/tests/webdriver/tests/get_current_url/get.py
@@ -7,100 +7,101 @@ from tests.support.asserts import assert
 from tests.support.wait import wait
 
 alert_doc = inline("<script>window.alert()</script>")
 frame_doc = inline("<p>frame")
 one_frame_doc = inline("<iframe src='%s'></iframe>" % frame_doc)
 two_frames_doc = inline("<iframe src='%s'></iframe>" % one_frame_doc)
 
 
+def get_current_url(session):
+    return session.transport.send(
+        "GET", "session/{session_id}/url".format(**vars(session)))
+
 # TODO(ato): 7.1 Get
 
 
 def test_get_current_url_no_browsing_context(session, create_window):
     # 7.2 step 1
     session.window_handle = create_window()
     session.close()
 
-    result = session.transport.send("GET", "session/%s/url" % session.session_id)
-
+    result = get_current_url(session)
     assert_error(result, "no such window")
 
 
 def test_get_current_url_alert_prompt(session):
     # 7.2 step 2
     session.url = alert_doc
 
-    result = session.transport.send("GET", "session/%s/url" % session.session_id)
-
+    result = get_current_url(session)
     assert_error(result, "unexpected alert open")
 
 def test_get_current_url_matches_location(session):
     # 7.2 step 3
     url = session.execute_script("return window.location.href")
-    assert session.url == url
+
+    result = get_current_url(session)
+    assert_success(result, url)
 
 def test_get_current_url_payload(session):
     # 7.2 step 4-5
     session.start()
 
-    result = session.transport.send("GET", "session/%s/url" % session.session_id)
-
+    result = get_current_url(session)
     assert result.status == 200
     assert isinstance(result.body["value"], basestring)
 
 def test_get_current_url_special_pages(session):
     session.url = "about:blank"
 
-    result = session.transport.send("GET", "session/%s/url" % session.session_id)
-
+    result = get_current_url(session)
     assert_success(result, "about:blank")
 
 # TODO(ato): This test requires modification to pass on Windows
 def test_get_current_url_file_protocol(session):
     # tests that the browsing context remains the same
     # when navigated privileged documents
     session.url = "file:///"
 
-    result = session.transport.send("GET", "session/%s/url" % session.session_id)
-
+    result = get_current_url(session)
     assert_success(result, "file:///")
 
 # TODO(ato): Test for http:// and https:// protocols.
 # We need to expose a fixture for accessing
 # documents served by wptserve in order to test this.
 
 def test_set_malformed_url(session):
     result = session.transport.send("POST",
                                     "session/%s/url" % session.session_id,
                                     {"url": "foo"})
 
     assert_error(result, "invalid argument")
 
 def test_get_current_url_after_modified_location(session):
-    start = session.transport.send("GET", "session/%s/url" % session.session_id)
+    start = get_current_url(session)
     session.execute_script("window.location.href = 'about:blank#wd_test_modification'")
     wait(session,
-         lambda s: s.transport.send("GET", "session/%s/url" % session.session_id) != start.body["value"],
+         lambda _: get_current_url(session).body["value"] != start.body["value"],
          "URL did not change")
-    result = session.transport.send("GET", "session/%s/url" % session.session_id)
 
+    result = get_current_url(session)
     assert_success(result, "about:blank#wd_test_modification")
 
 def test_get_current_url_nested_browsing_context(session, create_frame):
     session.url = "about:blank#wd_from_within_frame"
     session.switch_frame(create_frame())
 
-    result = session.transport.send("GET", "session/%s/url" % session.session_id)
-
+    result = get_current_url(session)
     assert_success(result, "about:blank#wd_from_within_frame")
 
 def test_get_current_url_nested_browsing_contexts(session):
     session.url = two_frames_doc
     top_level_url = session.url
 
     outer_frame = session.find.css("iframe", all=False)
     session.switch_frame(outer_frame)
 
     inner_frame = session.find.css("iframe", all=False)
     session.switch_frame(inner_frame)
 
-    assert session.url == top_level_url
+    result = get_current_url(session)
+    assert_success(result, top_level_url)
--- a/testing/web-platform/tests/webdriver/tests/get_element_attribute/get.py
+++ b/testing/web-platform/tests/webdriver/tests/get_element_attribute/get.py
@@ -2,147 +2,148 @@
 
 import pytest
 
 from tests.support.asserts import assert_error, assert_success, assert_dialog_handled
 from tests.support.fixtures import create_dialog
 from tests.support.inline import inline
 
 
-def get_attribute(session, element, attr):
-    return session.transport.send("GET", "session/{session_id}/element/{element_id}/attribute/{attr}"
-                                  .format(session_id=session.session_id,
-                                          element_id=element,
-                                          attr=attr))
+def get_element_attribute(session, element, attr):
+    return session.transport.send(
+        "GET", "session/{session_id}/element/{element_id}/attribute/{attr}".format(
+            session_id=session.session_id,
+            element_id=element,
+            attr=attr))
 
 
 # 13.2 Get Element Attribute
 
 def test_no_browsing_context(session, create_window):
     # 13.2 step 1
     session.window_handle = create_window()
     session.close()
 
-    result = get_attribute(session, "foo", "id")
+    result = get_element_attribute(session, "foo", "id")
 
     assert_error(result, "no such window")
 
 
 def test_handle_prompt_dismiss(new_session, add_browser_capabilites):
     # 13.2 step 2
     _, session = new_session({"capabilities": {"alwaysMatch": add_browser_capabilites({"unhandledPromptBehavior": "dismiss"})}})
     session.url = inline("<input id=foo>")
     element = session.find.css("#foo", all=False)
 
     create_dialog(session)("alert", text="dismiss #1", result_var="dismiss1")
 
-    result = get_attribute(session, element.id, "id")
+    result = get_element_attribute(session, element.id, "id")
 
     assert_success(result, "foo")
     assert_dialog_handled(session, "dismiss #1")
 
     create_dialog(session)("confirm", text="dismiss #2", result_var="dismiss2")
 
-    result = get_attribute(session, element.id, "id")
+    result = get_element_attribute(session, element.id, "id")
 
     assert_success(result, "foo")
     assert_dialog_handled(session, "dismiss #2")
 
     create_dialog(session)("prompt", text="dismiss #3", result_var="dismiss3")
 
-    result = get_attribute(session, element.id, "id")
+    result = get_element_attribute(session, element.id, "id")
 
     assert_success(result, "foo")
     assert_dialog_handled(session, "dismiss #3")
 
 
 def test_handle_prompt_accept(new_session, add_browser_capabilites):
     # 13.2 step 2
     _, session = new_session({"capabilities": {"alwaysMatch": add_browser_capabilites({"unhandledPromptBehavior": "accept"})}})
     session.url = inline("<input id=foo>")
     element = session.find.css("#foo", all=False)
 
     create_dialog(session)("alert", text="dismiss #1", result_var="dismiss1")
 
-    result = get_attribute(session, element.id, "id")
+    result = get_element_attribute(session, element.id, "id")
 
     assert_success(result, "foo")
     assert_dialog_handled(session, "dismiss #1")
 
     create_dialog(session)("confirm", text="dismiss #2", result_var="dismiss2")
 
-    result = get_attribute(session, element.id, "id")
+    result = get_element_attribute(session, element.id, "id")
 
     assert_success(result, "foo")
     assert_dialog_handled(session, "dismiss #2")
 
     create_dialog(session)("prompt", text="dismiss #3", result_var="dismiss3")
 
-    result = get_attribute(session, element.id, "id")
+    result = get_element_attribute(session, element.id, "id")
 
     assert_success(result, "foo")
     assert_dialog_handled(session, "dismiss #3")
 
 
 def test_handle_prompt_missing_value(session):
     # 13.2 step 2
     session.url = inline("<input id=foo>")
     element = session.find.css("#foo", all=False)
 
     create_dialog(session)("alert", text="dismiss #1", result_var="dismiss1")
 
-    result = get_attribute(session, element.id, "id")
+    result = get_element_attribute(session, element.id, "id")
 
     assert_error(result, "unexpected alert open")
     assert_dialog_handled(session, "dismiss #1")
 
     create_dialog(session)("confirm", text="dismiss #2", result_var="dismiss2")
 
-    result = get_attribute(session, element.id, "id")
+    result = get_element_attribute(session, element.id, "id")
 
     assert_error(result, "unexpected alert open")
     assert_dialog_handled(session, "dismiss #2")
 
     create_dialog(session)("prompt", text="dismiss #3", result_var="dismiss3")
 
-    result = get_attribute(session, element.id, "id")
+    result = get_element_attribute(session, element.id, "id")
 
     assert_error(result, "unexpected alert open")
     assert_dialog_handled(session, "dismiss #3")
 
 
 def test_element_not_found(session):
     # 13.2 Step 3
-    result = get_attribute(session, "foo", "id")
+    result = get_element_attribute(session, "foo", "id")
 
     assert_error(result, "no such element")
 
 
 def test_element_stale(session):
     # 13.2 step 4
     session.url = inline("<input id=foo>")
     element = session.find.css("input", all=False)
     session.refresh()
-    result = get_attribute(session, element.id, "id")
+    result = get_element_attribute(session, element.id, "id")
 
     assert_error(result, "stale element reference")
 
 
 def test_normal(session):
     # 13.2 Step 5
     session.url = inline("<input type=checkbox>")
     element = session.find.css("input", all=False)
-    result = get_attribute(session, element.id, "input")
+    result = get_element_attribute(session, element.id, "input")
     assert_success(result, None)
     assert False == session.execute_script("return document.querySelector('input').checked")
 
     # Check we are not returning the property which will have a different value
     element.click()
     assert True == session.execute_script("return document.querySelector('input').checked")
-    result = get_attribute(session, element.id, "input")
+    result = get_element_attribute(session, element.id, "input")
     assert_success(result, None)
 
 
 @pytest.mark.parametrize("tag,attrs", [
     ("audio", ["autoplay", "controls", "loop", "muted"]),
     ("button", ["autofocus", "disabled", "formnovalidate"]),
     ("details", ["open"]),
     ("dialog", ["open"]),
@@ -163,35 +164,35 @@ def test_normal(session):
     ("video", ["autoplay", "controls", "loop", "muted"])
 ])
 def test_boolean_attribute(session, tag, attrs):
     # 13.2 Step 5
     for attr in attrs:
         session.url = inline("<{0} {1}>".format(tag, attr))
 
         element = session.find.css(tag, all=False)
-        result = result = get_attribute(session, element.id, attr)
+        result = result = get_element_attribute(session, element.id, attr)
         assert_success(result, "true")
 
 
 def test_global_boolean_attributes(session):
     # 13.2 Step 5
     session.url = inline("<p hidden>foo")
     element = session.find.css("p", all=False)
-    result = result = get_attribute(session, element.id, "hidden")
+    result = result = get_element_attribute(session, element.id, "hidden")
 
     assert_success(result, "true")
 
     session.url = inline("<p>foo")
     element = session.find.css("p", all=False)
-    result = result = get_attribute(session, element.id, "hidden")
+    result = result = get_element_attribute(session, element.id, "hidden")
     assert_success(result, None)
 
     session.url = inline("<p itemscope>foo")
     element = session.find.css("p", all=False)
-    result = result = get_attribute(session, element.id, "itemscope")
+    result = result = get_element_attribute(session, element.id, "itemscope")
 
     assert_success(result, "true")
 
     session.url = inline("<p>foo")
     element = session.find.css("p", all=False)
-    result = result = get_attribute(session, element.id, "itemscope")
+    result = result = get_element_attribute(session, element.id, "itemscope")
     assert_success(result, None)
--- a/testing/web-platform/tests/webdriver/tests/get_element_property/get.py
+++ b/testing/web-platform/tests/webdriver/tests/get_element_property/get.py
@@ -4,165 +4,136 @@ from tests.support.asserts import assert
 from tests.support.inline import inline
 from tests.support.fixtures import create_dialog
 
 _input = inline("<input id=i1>")
 
 
 # 13.3 Get Element Property
 
+
+def get_element_property(session, element_id, prop):
+    return session.transport.send(
+        "GET", "session/{session_id}/element/{element_id}/property/{prop}".format(
+            session_id=session.session_id,
+            element_id=element_id,
+            prop=prop))
+
+
 def test_no_browsing_context(session, create_window):
     # 13.3 step 1
     session.window_handle = create_window()
     session.close()
 
-    result = session.transport.send("GET", "session/{session_id}/element/{element_id}/property/id"
-                                    .format(session_id=session.session_id,
-                                            element_id="foo"))
-
+    result = get_element_property(session, "foo", "id")
     assert_error(result, "no such window")
 
 
 def test_handle_prompt_dismiss(new_session, add_browser_capabilites):
     # 13.3 step 2
     _, session = new_session({"capabilities": {"alwaysMatch": add_browser_capabilites({"unhandledPromptBehavior": "dismiss"})}})
     session.url = inline("<input id=foo>")
     element = session.find.css("#foo", all=False)
 
     create_dialog(session)("alert", text="dismiss #1", result_var="dismiss1")
 
-    result = session.transport.send("GET", "session/{session_id}/element/{element_id}/property/id"
-                                    .format(session_id=session.session_id,
-                                            element_id=element.id))
-
+    result = get_element_property(session, element.id, "id")
     assert_success(result, "foo")
     assert_dialog_handled(session, "dismiss #1")
 
     create_dialog(session)("confirm", text="dismiss #2", result_var="dismiss2")
 
-    result = session.transport.send("GET", "session/{session_id}/element/{element_id}/property/id"
-                                    .format(session_id=session.session_id,
-                                            element_id=element.id))
-
+    result = get_element_property(session, element.id, "id")
     assert_success(result, "foo")
     assert_dialog_handled(session, "dismiss #2")
 
     create_dialog(session)("prompt", text="dismiss #3", result_var="dismiss3")
 
-    result = session.transport.send("GET", "session/{session_id}/element/{element_id}/property/id"
-                                    .format(session_id=session.session_id,
-                                            element_id=element.id))
-
+    result = get_element_property(session, element.id, "id")
     assert_success(result, "foo")
     assert_dialog_handled(session, "dismiss #3")
 
 
 
 def test_handle_prompt_accept(new_session, add_browser_capabilites):
     # 13.3 step 2
     _, session = new_session({"capabilities": {"alwaysMatch": add_browser_capabilites({"unhandledPromptBehavior": "accept"})}})
     session.url = inline("<input id=foo>")
     element = session.find.css("#foo", all=False)
 
     create_dialog(session)("alert", text="dismiss #1", result_var="dismiss1")
 
-    result = session.transport.send("GET", "session/{session_id}/element/{element_id}/property/id"
-                                    .format(session_id=session.session_id,
-                                            element_id=element.id))
-
+    result = get_element_property(session, element.id, "id")
     assert_success(result, "foo")
     assert_dialog_handled(session, "dismiss #1")
 
     create_dialog(session)("confirm", text="dismiss #2", result_var="dismiss2")
 
-    result = session.transport.send("GET", "session/{session_id}/element/{element_id}/property/id"
-                                    .format(session_id=session.session_id,
-                                            element_id=element.id))
-
+    result = get_element_property(session, element.id, "id")
     assert_success(result, "foo")
     assert_dialog_handled(session, "dismiss #2")
 
     create_dialog(session)("prompt", text="dismiss #3", result_var="dismiss3")
 
-    result = session.transport.send("GET", "session/{session_id}/element/{element_id}/property/id"
-                                    .format(session_id=session.session_id,
-                                            element_id=element.id))
-
+    result = get_element_property(session, element.id, "id")
     assert_success(result, "foo")
     assert_dialog_handled(session, "dismiss #3")
 
 
 def test_handle_prompt_missing_value(session):
     # 13.3 step 2
     session.url = inline("<input id=foo>")
     element = session.find.css("#foo", all=False)
 
     create_dialog(session)("alert", text="dismiss #1", result_var="dismiss1")
 
-    result = session.transport.send("GET", "session/{session_id}/element/{element_id}/property/id"
-                                    .format(session_id=session.session_id,
-                                            element_id=element.id))
-
+    result = get_element_property(session, element.id, "id")
     assert_error(result, "unexpected alert open")
     assert_dialog_handled(session, "dismiss #1")
 
     create_dialog(session)("confirm", text="dismiss #2", result_var="dismiss2")
 
-    result = session.transport.send("GET", "session/{session_id}/element/{element_id}/property/id"
-                                    .format(session_id=session.session_id,
-                                            element_id=element.id))
-
+    result = get_element_property(session, element.id, "id")
     assert_error(result, "unexpected alert open")
     assert_dialog_handled(session, "dismiss #2")
 
     create_dialog(session)("prompt", text="dismiss #3", result_var="dismiss3")
 
-    result = session.transport.send("GET", "session/{session_id}/element/{element_id}/property/id"
-                                    .format(session_id=session.session_id,
-                                            element_id=element.id))
-
+    result = get_element_property(session, element.id, "id")
     assert_error(result, "unexpected alert open")
     assert_dialog_handled(session, "dismiss #3")
 
 def test_element_not_found(session):
     # 13.3 Step 3
-    result = session.transport.send("GET", "session/{session_id}/element/{element_id}/property/id"
-                                    .format(session_id=session.session_id,
-                                            element_id="foo"))
-
+    result = get_element_property(session, "foo", "id")
     assert_error(result, "no such element")
 
 
 def test_element_stale(session):
     # 13.3 step 4
     session.url = _input
     element = session.find.css("input", all=False)
     session.refresh()
-    result = session.transport.send("GET", "session/{session_id}/element/{element_id}/property/id"
-                                    .format(session_id=session.session_id,
-                                            element_id=element.id))
 
+    result = get_element_property(session, element.id, "id")
     assert_error(result, "stale element reference")
 
 
 def test_element_non_existent(session):
     # 13.3 step 5-7
     session.url = _input
     element = session.find.css("input", all=False)
-    result = session.transport.send("GET", "session/{session_id}/element/{element_id}/property/foo"
-                                    .format(session_id=session.session_id,
-                                            element_id=element.id))
 
+    result = get_element_property(session, element.id, "foo")
     assert_success(result, None)
     assert None == session.execute_script("return arguments[0].foo",
                                           args=[element])
 
 
 def test_element(session):
     # 13.3 step 5-7
     session.url = inline("<input type=checkbox>")
     element = session.find.css("input", all=False)
     element.click()
     assert session.execute_script("return arguments[0].hasAttribute('checked')", args=(element,)) is False
-    result = session.transport.send("GET", "session/{session_id}/element/{element_id}/property/checked"
-                                    .format(session_id=session.session_id,
-                                            element_id=element.id))
+
+    result = get_element_property(session, element.id, "checked")
     assert_success(result, True)
--- a/testing/web-platform/tests/webdriver/tests/get_element_tag_name/get.py
+++ b/testing/web-platform/tests/webdriver/tests/get_element_tag_name/get.py
@@ -2,150 +2,122 @@
 
 from tests.support.asserts import assert_error, assert_dialog_handled, assert_success
 from tests.support.inline import inline
 from tests.support.fixtures import create_dialog
 
 
 # 13.6 Get Element Tag Name
 
+
+def get_element_tag_name(session, element_id):
+    return session.transport.send(
+        "GET", "session/{session_id}/element/{element_id}/name".format(
+            session_id=session.session_id,
+            element_id=element_id))
+
+
 def test_no_browsing_context(session, create_window):
     # 13.6 step 1
     session.window_handle = create_window()
     session.close()
 
-    result = session.transport.send("GET", "session/{session_id}/element/{element_id}/name"
-                                    .format(session_id=session.session_id,
-                                            element_id="foo"))
-
+    result = get_element_tag_name(session, "foo")
     assert_error(result, "no such window")
 
 
 def test_handle_prompt_dismiss(new_session, add_browser_capabilites):
     # 13.6 step 2
     _, session = new_session({"capabilities": {"alwaysMatch": add_browser_capabilites({"unhandledPromptBehavior": "dismiss"})}})
     session.url = inline("<input id=foo>")
     element = session.find.css("#foo", all=False)
 
     create_dialog(session)("alert", text="dismiss #1", result_var="dismiss1")
 
-    result = session.transport.send("GET", "session/{session_id}/element/{element_id}/name"
-                                    .format(session_id=session.session_id,
-                                            element_id=element.id))
-
+    result = get_element_tag_name(session, element.id)
     assert_success(result, "input")
     assert_dialog_handled(session, "dismiss #1")
 
     create_dialog(session)("confirm", text="dismiss #2", result_var="dismiss2")
 
-    result = session.transport.send("GET", "session/{session_id}/element/{element_id}/name"
-                                    .format(session_id=session.session_id,
-                                            element_id=element.id))
-
+    result = get_element_tag_name(session, element.id)
     assert_success(result, "input")
     assert_dialog_handled(session, "dismiss #2")
 
     create_dialog(session)("prompt", text="dismiss #3", result_var="dismiss3")
 
-    result = session.transport.send("GET", "session/{session_id}/element/{element_id}/name"
-                                    .format(session_id=session.session_id,
-                                            element_id=element.id))
-
+    result = get_element_tag_name(session, element.id)
     assert_success(result, "input")
     assert_dialog_handled(session, "dismiss #3")
 
 
 def test_handle_prompt_accept(new_session, add_browser_capabilites):
     # 13.6 step 2
     _, session = new_session({"capabilities": {"alwaysMatch": add_browser_capabilites({"unhandledPromptBehavior": "accept"})}})
     session.url = inline("<input id=foo>")
     element = session.find.css("#foo", all=False)
 
     create_dialog(session)("alert", text="dismiss #1", result_var="dismiss1")
 
-    result = session.transport.send("GET", "session/{session_id}/element/{element_id}/name"
-                                    .format(session_id=session.session_id,
-                                            element_id=element.id))
-
+    result = get_element_tag_name(session, element.id)
     assert_success(result, "input")
     assert_dialog_handled(session, "dismiss #1")
 
     create_dialog(session)("confirm", text="dismiss #2", result_var="dismiss2")
 
-    result = session.transport.send("GET", "session/{session_id}/element/{element_id}/name"
-                                    .format(session_id=session.session_id,
-                                            element_id=element.id))
-
+    result = get_element_tag_name(session, element.id)
     assert_success(result, "input")
     assert_dialog_handled(session, "dismiss #2")
 
     create_dialog(session)("prompt", text="dismiss #3", result_var="dismiss3")
 
-    result = session.transport.send("GET", "session/{session_id}/element/{element_id}/name"
-                                    .format(session_id=session.session_id,
-                                            element_id=element.id))
-
+    result = get_element_tag_name(session, element.id)
     assert_success(result, "input")
     assert_dialog_handled(session, "dismiss #3")
 
 
 def test_handle_prompt_missing_value(session):
     # 13.6 step 2
     session.url = inline("<input id=foo>")
     element = session.find.css("#foo", all=False)
 
     create_dialog(session)("alert", text="dismiss #1", result_var="dismiss1")
 
-    result = session.transport.send("GET", "session/{session_id}/element/{element_id}/name"
-                                    .format(session_id=session.session_id,
-                                            element_id=element.id))
-
+    result = get_element_tag_name(session, element.id)
     assert_error(result, "unexpected alert open")
     assert_dialog_handled(session, "dismiss #1")
 
     create_dialog(session)("confirm", text="dismiss #2", result_var="dismiss2")
 
-    result = session.transport.send("GET", "session/{session_id}/element/{element_id}/name"
-                                    .format(session_id=session.session_id,
-                                            element_id=element.id))
-
+    result = get_element_tag_name(session, element.id)
     assert_error(result, "unexpected alert open")
     assert_dialog_handled(session, "dismiss #2")
 
     create_dialog(session)("prompt", text="dismiss #3", result_var="dismiss3")
 
-    result = session.transport.send("GET", "session/{session_id}/element/{element_id}/name"
-                                    .format(session_id=session.session_id,
-                                            element_id=element.id))
-
+    result = get_element_tag_name(session, element.id)
     assert_error(result, "unexpected alert open")
     assert_dialog_handled(session, "dismiss #3")
 
 
 def test_element_not_found(session):
     # 13.6 Step 3
-    result = session.transport.send("GET", "session/{session_id}/element/{element_id}/name"
-                                    .format(session_id=session.session_id,
-                                            element_id="foo"))
-
+    result = get_element_tag_name(session, "foo")
     assert_error(result, "no such element")
 
 
 def test_element_stale(session):
     # 13.6 step 4
     session.url = inline("<input id=foo>")
     element = session.find.css("input", all=False)
     session.refresh()
-    result = session.transport.send("GET", "session/{session_id}/element/{element_id}/name"
-                                    .format(session_id=session.session_id,
-                                            element_id=element.id))
 
+    result = get_element_tag_name(session, element.id)
     assert_error(result, "stale element reference")
 
 
 def test_get_element_tag_name(session):
     # 13.6 step 6
     session.url = inline("<input id=foo>")
     element = session.find.css("input", all=False)
-    result = session.transport.send("GET", "session/{session_id}/element/{element_id}/name"
-                                    .format(session_id=session.session_id,
-                                            element_id=element.id))
+
+    result = get_element_tag_name(session, element.id)
     assert_success(result, "input")
--- a/testing/web-platform/tests/webdriver/tests/get_element_text/get.py
+++ b/testing/web-platform/tests/webdriver/tests/get_element_text/get.py
@@ -1,29 +1,33 @@
 import pytest
-import uuid
 
 from tests.support.asserts import assert_error, assert_success
 from tests.support.inline import inline
 
 # For failing tests, the Get Element Text end-point is used
 # directly. In all other cases, the Element.text() function is used.
 
-def test_getting_text_of_a_non_existant_element_is_an_error(session):
-   session.url = inline("""<body>Hello world</body>""")
-   id = uuid.uuid4()
+
+def get_element_text(session, element_id):
+    return session.transport.send(
+        "GET", "session/{session_id}/element/{element_id}/text".format(
+            session_id=session.session_id,
+            element_id=element_id))
 
-   result = session.transport.send(
-       "GET",
-       "session/%s/element/%s/text" % (session.session_id, id))
 
-   assert_error(result, "no such element")
+def test_getting_text_of_a_non_existant_element_is_an_error(session):
+    session.url = inline("""<body>Hello world</body>""")
+
+    result = get_element_text(session, "foo")
+    assert_error(result, "no such element")
 
 
 def test_read_element_text(session):
     session.url = inline("""
         <body>
           Noise before <span id='id'>This has an ID</span>. Noise after
         </body>""")
 
     element = session.find.css("#id", all=False)
 
-    assert element.text == "This has an ID"
+    result = get_element_text(session, element.id)
+    assert_success(result, "This has an ID")
--- a/testing/web-platform/tests/webdriver/tests/get_named_cookie/get.py
+++ b/testing/web-platform/tests/webdriver/tests/get_named_cookie/get.py
@@ -1,24 +1,32 @@
+from tests.support.asserts import assert_success
 from tests.support.inline import inline
 from tests.support.fixtures import clear_all_cookies
 from datetime import datetime, timedelta
 
+
+def get_named_cookie(session, cookie_name):
+    return session.transport.send(
+        "GET", "session/{session_id}/cookie/{cookie_name}".format(
+            session_id=session.session_id,
+            cookie_name=cookie_name))
+
+
 def test_get_named_session_cookie(session, url):
     session.url = url("/common/blank.html")
     clear_all_cookies(session)
     session.execute_script("document.cookie = 'foo=bar'")
 
-    result = session.transport.send("GET", "session/%s/cookie/foo" % session.session_id)
-    assert result.status == 200
-    assert isinstance(result.body["value"], dict)
+    result = get_named_cookie(session, "foo")
+    cookie = assert_success(result)
+    assert isinstance(cookie, dict)
 
     # table for cookie conversion
     # https://w3c.github.io/webdriver/webdriver-spec.html#dfn-table-for-cookie-conversion
-    cookie = result.body["value"]
     assert "name" in cookie
     assert isinstance(cookie["name"], basestring)
     assert "value" in cookie
     assert isinstance(cookie["value"], basestring)
     assert "path" in cookie
     assert isinstance(cookie["path"], basestring)
     assert "domain" in cookie
     assert isinstance(cookie["domain"], basestring)
@@ -36,24 +44,20 @@ def test_get_named_cookie(session, url):
     session.url = url("/common/blank.html")
     clear_all_cookies(session)
 
     # same formatting as Date.toUTCString() in javascript
     utc_string_format = "%a, %d %b %Y %H:%M:%S"
     a_year_from_now = (datetime.utcnow() + timedelta(days=365)).strftime(utc_string_format)
     session.execute_script("document.cookie = 'foo=bar;expires=%s'" % a_year_from_now)
 
-    result = session.transport.send("GET", "session/%s/cookie" % session.session_id)
-    assert result.status == 200
-    assert "value" in result.body
-    assert isinstance(result.body["value"], list)
-    assert len(result.body["value"]) == 1
-    assert isinstance(result.body["value"][0], dict)
+    result = get_named_cookie(session, "foo")
+    cookie = assert_success(result)
+    assert isinstance(cookie, dict)
 
-    cookie = result.body["value"][0]
     assert "name" in cookie
     assert isinstance(cookie["name"], basestring)
     assert "value" in cookie
     assert isinstance(cookie["value"], basestring)
     assert "expiry" in cookie
     assert isinstance(cookie["expiry"], (int, long))
 
     assert cookie["name"] == "foo"
@@ -75,23 +79,20 @@ def test_duplicated_cookie(session, url,
         }
     }
     result = session.transport.send("POST", "session/%s/cookie" % session.session_id, create_cookie_request)
     assert result.status == 200
     assert "value" in result.body
     assert result.body["value"] is None
 
     session.url = inline("<script>document.cookie = 'hello=newworld; domain=%s; path=/';</script>" % server_config["domains"][""])
-    result = session.transport.send("GET", "session/%s/cookie" % session.session_id)
-    assert result.status == 200
-    assert "value" in result.body
-    assert isinstance(result.body["value"], list)
-    assert len(result.body["value"]) == 1
-    assert isinstance(result.body["value"][0], dict)
 
-    cookie = result.body["value"][0]
+    result = get_named_cookie(session, "hello")
+    cookie = assert_success(result)
+    assert isinstance(cookie, dict)
+
     assert "name" in cookie
     assert isinstance(cookie["name"], basestring)
     assert "value" in cookie
     assert isinstance(cookie["value"], basestring)
 
     assert cookie["name"] == "hello"
     assert cookie["value"] == "newworld"
--- a/testing/web-platform/tests/webdriver/tests/get_timeouts/get.py
+++ b/testing/web-platform/tests/webdriver/tests/get_timeouts/get.py
@@ -1,14 +1,15 @@
 from tests.support.asserts import assert_success
 
 
 def get_timeouts(session):
-    return session.transport.send("GET", "session/{session_id}/timeouts"
-                                  .format(session_id=session.session_id))
+    return session.transport.send(
+        "GET", "session/{session_id}/timeouts".format(
+            session_id=session.session_id))
 
 
 # 8.4 Get Timeouts
 
 def test_get_timeouts(session):
     # 8.4 step 1
     response = get_timeouts(session)
 
new file mode 100644
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/webdriver/tests/get_title/conftest.py
@@ -0,0 +1,10 @@
+import pytest
+
+
+@pytest.fixture
+def get_title(session):
+    def _get_title():
+        return session.transport.send(
+            "GET", "session/{session_id}/title".format(**vars(session)))
+
+    return _get_title
--- a/testing/web-platform/tests/webdriver/tests/get_title/get.py
+++ b/testing/web-platform/tests/webdriver/tests/get_title/get.py
@@ -1,73 +1,63 @@
-import pytest
-import time
-
 from tests.support.asserts import assert_error, assert_success, assert_dialog_handled
 from tests.support.fixtures import create_dialog
 from tests.support.inline import inline
 
 def read_global(session, name):
     return session.execute_script("return %s;" % name)
 
+
 # 1. If the current top-level browsing context is no longer open, return error
 #    with error code no such window.
-def test_title_from_closed_context(session, create_window):
+def test_title_from_closed_context(session, get_title, create_window):
     new_window = create_window()
     session.window_handle = new_window
     session.close()
 
-    result = session.transport.send("GET",
-                                    "session/%s/title" % session.session_id)
-
+    result = get_title()
     assert_error(result, "no such window")
 
 # [...]
 # 2. Handle any user prompts and return its value if it is an error.
 # [...]
 # In order to handle any user prompts a remote end must take the following
 # steps:
 # 2. Run the substeps of the first matching user prompt handler:
 #
 #    [...]
 #    - dismiss state
 #      1. Dismiss the current user prompt.
 #    [...]
 #
 # 3. Return success.
-def test_title_handle_prompt_dismiss(new_session, add_browser_capabilites):
+def test_title_handle_prompt_dismiss(new_session, add_browser_capabilites, get_title):
     _, session = new_session({"capabilities": {"alwaysMatch": add_browser_capabilites({"unhandledPromptBehavior": "dismiss"})}})
     session.url = inline("<title>WD doc title</title>")
 
     expected_title = read_global(session, "document.title")
     create_dialog(session)("alert", text="dismiss #1", result_var="dismiss1")
 
-    result = session.transport.send("GET",
-                                    "session/%s/title" % session.session_id)
-
+    result = get_title()
     assert_success(result, expected_title)
     assert_dialog_handled(session, "dismiss #1")
     assert read_global(session, "dismiss1") == None
 
     expected_title = read_global(session, "document.title")
     create_dialog(session)("confirm", text="dismiss #2", result_var="dismiss2")
 
-    result = session.transport.send("GET",
-                                    "session/%s/title" % session.session_id)
-
+    result = get_title()
     assert_success(result, expected_title)
     assert_dialog_handled(session, "dismiss #2")
     assert read_global(session, "dismiss2") == False
 
     expected_title = read_global(session, "document.title")
     create_dialog(session)("prompt", text="dismiss #3", result_var="dismiss3")
 
-    result = session.transport.send("GET",
-                                    "session/%s/title" % session.session_id)
-
+    result = get_title()
     assert_success(result, expected_title)
     assert_dialog_handled(session, "dismiss #3")
     assert read_global(session, "dismiss3") == None
 
 # [...]
 # 2. Handle any user prompts and return its value if it is an error.
 # [...]
 # In order to handle any user prompts a remote end must take the following
@@ -75,95 +65,84 @@ def test_title_handle_prompt_dismiss(new
 # 2. Run the substeps of the first matching user prompt handler:
 #
 #    [...]
 #    - accept state
 #      1. Accept the current user prompt.
 #    [...]
 #
 # 3. Return success.
-def test_title_handle_prompt_accept(new_session, add_browser_capabilites):
+def test_title_handle_prompt_accept(new_session, add_browser_capabilites, get_title):
     _, session = new_session({"capabilities": {"alwaysMatch": add_browser_capabilites({"unhandledPromptBehavior": "accept"})}})
     session.url = inline("<title>WD doc title</title>")
     create_dialog(session)("alert", text="accept #1", result_var="accept1")
 
     expected_title = read_global(session, "document.title")
-    result = session.transport.send("GET",
-                                    "session/%s/title" % session.session_id)
 
+    result = get_title()
     assert_success(result, expected_title)
     assert_dialog_handled(session, "accept #1")
     assert read_global(session, "accept1") == None
 
     expected_title = read_global(session, "document.title")
     create_dialog(session)("confirm", text="accept #2", result_var="accept2")
 
-    result = session.transport.send("GET",
-                                    "session/%s/title" % session.session_id)
-
+    result = get_title()
     assert_success(result, expected_title)
     assert_dialog_handled(session, "accept #2")
     assert read_global(session, "accept2") == True
 
     expected_title = read_global(session, "document.title")
     create_dialog(session)("prompt", text="accept #3", result_var="accept3")
 
-    result = session.transport.send("GET",
-                                    "session/%s/title" % session.session_id)
-
+    result = get_title()
     assert_success(result, expected_title)
     assert_dialog_handled(session, "accept #3")
     assert read_global(session, "accept3") == "" or read_global(session, "accept3") == "undefined"
 
 # [...]
 # 2. Handle any user prompts and return its value if it is an error.
 # [...]
 # In order to handle any user prompts a remote end must take the following
 # steps:
 # 2. Run the substeps of the first matching user prompt handler:
 #
 #    [...]
 #    - missing value default state
 #    - not in the table of simple dialogs
 #      1. Dismiss the current user prompt.
 #      2. Return error with error code unexpected alert open.
-def test_title_handle_prompt_missing_value(session, create_dialog):
+def test_title_handle_prompt_missing_value(session, create_dialog, get_title):
     session.url = inline("<title>WD doc title</title>")
     create_dialog("alert", text="dismiss #1", result_var="dismiss1")
 
-    result = session.transport.send("GET",
-                                    "session/%s/title" % session.session_id)
-
+    result = get_title()
     assert_error(result, "unexpected alert open")
     assert_dialog_handled(session, "dismiss #1")
     assert read_global(session, "dismiss1") == None
 
     create_dialog("confirm", text="dismiss #2", result_var="dismiss2")
 
-    result = session.transport.send("GET",
-                                    "session/%s/title" % session.session_id)
-
+    result = get_title()
     assert_error(result, "unexpected alert open")
     assert_dialog_handled(session, "dismiss #2")
     assert read_global(session, "dismiss2") == False
 
     create_dialog("prompt", text="dismiss #3", result_var="dismiss3")
 
-    result = session.transport.send("GET",
-                                    "session/%s/title" % session.session_id)
-
+    result = get_title()
     assert_error(result, "unexpected alert open")
     assert_dialog_handled(session, "dismiss #3")
     assert read_global(session, "dismiss3") == None
 
 # The behavior of the `window.print` function is platform-dependent and may not
 # trigger the creation of a dialog at all. Therefore, this test should only be
 # run in contexts that support the dialog (a condition that may not be
 # determined automatically).
-#def test_title_with_non_simple_dialog(session):
+#def tst_title_with_non_simple_dialog(session):
 #    document = "<title>With non-simple dialog</title><h2>Hello</h2>"
 #    spawn = """
 #        var done = arguments[0];
 #        setTimeout(function() {
 #            done();
 #        }, 0);
 #        setTimeout(function() {
 #            window['print']();
@@ -181,102 +160,91 @@ def test_title_handle_prompt_missing_val
 #    top-level browsing context's active document.
 # 4. Return success with data title.
 # [...]
 # The title attribute must, on getting, run the following algorithm:
 # [...]
 # 2. Otherwise, let value be the child text content of the title element [...]
 # [...]
 # 4. Return value.
-def test_title_from_top_context(session):
+def test_title_from_top_context(session, get_title):
     session.url = inline("<title>Foobar</title><h2>Hello</h2>")
 
-    result = session.transport.send("GET",
-                                    "session/%s/title" % session.session_id)
+    result = get_title()
     assert_success(result, read_global(session, "document.title"))
 
 # [...]
 # 3. Let title be the initial value of the title IDL attribute of the current
 #    top-level browsing context's active document.
 # 4. Return success with data title.
 # [...]
 # The title attribute must, on getting, run the following algorithm:
 # [...]
 # 2. Otherwise, let value be the child text content of the title element [...]
 #
 #    The title element of a document is the first title element in the document
 #    (in tree order), if there is one, or null otherwise.
 #
 # [...]
 # 4. Return value.
-def test_title_with_duplicate_element(session):
+def test_title_with_duplicate_element(session, get_title):
     session.url = inline("<title>First</title><title>Second</title>")
 
-    result = session.transport.send("GET",
-                                    "session/%s/title" % session.session_id)
-
+    result = get_title()
     assert_success(result, read_global(session, "document.title"))
 
 # [...]
 # 3. Let title be the initial value of the title IDL attribute of the current
 #    top-level browsing context's active document.
 # 4. Return success with data title.
 # [...]
 # The title attribute must, on getting, run the following algorithm:
 # [...]
 # 2. Otherwise, let value be the child text content of the title element, or
 #    the empty string if the title element is null.
 # [...]
 # 4. Return value.
-def test_title_without_element(session):
+def test_title_without_element(session, get_title):
     session.url = inline("<h2>Hello</h2>")
 
-    result = session.transport.send("GET",
-                                    "session/%s/title" % session.session_id)
-
+    result = get_title()
     assert_success(result, read_global(session, "document.title"))
 
 # [...]
 # 3. Let title be the initial value of the title IDL attribute of the current
 #    top-level browsing context's active document.
 # 4. Return success with data title.
-def test_title_after_modification(session):
+def test_title_after_modification(session, get_title):
     session.url = inline("<title>Initial</title><h2>Hello</h2>")
     session.execute_script("document.title = 'updated'")
 
-    result = session.transport.send("GET",
-                                    "session/%s/title" % session.session_id)
-
+    result = get_title()
     assert_success(result, read_global(session, "document.title"))
 
 # [...]
 # 3. Let title be the initial value of the title IDL attribute of the current
 #    top-level browsing context's active document.
 # 4. Return success with data title.
 # [...]
 # The title attribute must, on getting, run the following algorithm:
 # [...]
 # 2. Otherwise, let value be the child text content of the title element [...]
 # 3. Strip and collapse ASCII whitespace in value.
 # 4. Return value.
-def test_title_strip_and_collapse(session):
+def test_title_strip_and_collapse(session, get_title):
     document = "<title>   a b\tc\nd\t \n e\t\n </title><h2>Hello</h2>"
     session.url = inline(document)
 
-    result = session.transport.send("GET",
-                                    "session/%s/title" % session.session_id)
-
+    result = get_title()
     assert_success(result, read_global(session, "document.title"))
 
 # [...]
 # 3. Let title be the initial value of the title IDL attribute of the current
 #    top-level browsing context's active document.
 # 4. Return success with data title.
-def test_title_from_frame(session, create_frame):
+def test_title_from_frame(session, create_frame,get_title):
     session.url = inline("<title>Parent</title>parent")
 
     session.switch_frame(create_frame())
     session.switch_frame(create_frame())
 
-    result = session.transport.send("GET",
-                                    "session/%s/title" % session.session_id)
-
+    result = get_title()
     assert_success(result, "Parent")
--- a/testing/web-platform/tests/webdriver/tests/get_window_rect/get.py
+++ b/testing/web-platform/tests/webdriver/tests/get_window_rect/get.py
@@ -2,17 +2,18 @@ from tests.support.asserts import assert
 from tests.support.fixtures import create_dialog
 from tests.support.inline import inline
 
 
 alert_doc = inline("<script>window.alert()</script>")
 
 
 def get_window_rect(session):
-    return session.transport.send("GET", "session/%s/window/rect" % session.session_id)
+    return session.transport.send(
+        "GET", "session/{session_id}/window/rect".format(**vars(session)))
 
 
 # 10.7.1 Get Window Rect
 
 
 def test_no_browsing_context(session, create_window):
     """
     1. If the current top-level browsing context is no longer open,
--- a/testing/web-platform/tests/webdriver/tests/is_element_selected/selected.py
+++ b/testing/web-platform/tests/webdriver/tests/is_element_selected/selected.py
@@ -11,175 +11,143 @@ option_doc = inline("""<select>
                         <option id=notSelected>r-</option>
                         <option id=selected selected>r+</option>
                        </select>
                     """)
 
 
 # 13.1 Is Element Selected
 
+
+def is_element_selected(session, element_id):
+    return session.transport.send(
+        "GET", "session/{session_id}/element/{element_id}/selected".format(
+            session_id=session.session_id,
+            element_id=element_id))
+
+
 def test_no_browsing_context(session, create_window):
     # 13.1 step 1
     session.window_handle = create_window()
     session.close()
 
-    result = session.transport.send("GET", "session/{session_id}/element/{element_id}/selected"
-                                    .format(session_id=session.session_id,
-                                            element_id="foo"))
-
+    result = is_element_selected(session, "foo")
     assert_error(result, "no such window")
 
 
 def test_handle_prompt_dismiss(new_session, add_browser_capabilites):
     # 13.1 step 2
     _, session = new_session({"capabilities": {"alwaysMatch": add_browser_capabilites({"unhandledPromptBehavior": "dismiss"})}})
     session.url = inline("<input id=foo>")
     element = session.find.css("#foo", all=False)
 
     create_dialog(session)("alert", text="dismiss #1", result_var="dismiss1")
 
-    result = session.transport.send("GET", "session/{session_id}/element/{element_id}/selected"
-                                    .format(session_id=session.session_id,
-                                            element_id=element.id))
-
+    result = is_element_selected(session, element.id)
     assert_success(result, False)
     assert_dialog_handled(session, "dismiss #1")
 
     create_dialog(session)("confirm", text="dismiss #2", result_var="dismiss2")
 
-    result = session.transport.send("GET", "session/{session_id}/element/{element_id}/selected"
-                                    .format(session_id=session.session_id,
-                                            element_id=element.id))
-
+    result = is_element_selected(session, element.id)
     assert_success(result, False)
     assert_dialog_handled(session, "dismiss #2")
 
     create_dialog(session)("prompt", text="dismiss #3", result_var="dismiss3")
 
-    result = session.transport.send("GET", "session/{session_id}/element/{element_id}/selected"
-                                    .format(session_id=session.session_id,
-                                            element_id=element.id))
-
+    result = is_element_selected(session, element.id)
     assert_success(result, False)
     assert_dialog_handled(session, "dismiss #3")
 
 
 def test_handle_prompt_accept(new_session, add_browser_capabilites):
     # 13.1 step 2
     _, session = new_session({"capabilities": {"alwaysMatch": add_browser_capabilites({"unhandledPromptBehavior": "accept"})}})
     session.url = inline("<input id=foo>")
     element = session.find.css("#foo", all=False)
 
     create_dialog(session)("alert", text="dismiss #1", result_var="dismiss1")
 
-    result = session.transport.send("GET", "session/{session_id}/element/{element_id}/selected"
-                                    .format(session_id=session.session_id,
-                                            element_id=element.id))
-
+    result = is_element_selected(session, element.id)
     assert_success(result, False)
     assert_dialog_handled(session, "dismiss #1")
 
     create_dialog(session)("confirm", text="dismiss #2", result_var="dismiss2")
 
-    result = session.transport.send("GET", "session/{session_id}/element/{element_id}/selected"
-                                    .format(session_id=session.session_id,
-                                            element_id=element.id))
-
+    result = is_element_selected(session, element.id)
     assert_success(result, False)
     assert_dialog_handled(session, "dismiss #2")
 
     create_dialog(session)("prompt", text="dismiss #3", result_var="dismiss3")
 
-    result = session.transport.send("GET", "session/{session_id}/element/{element_id}/selected"
-                                    .format(session_id=session.session_id,
-                                            element_id=element.id))
-
+    result = is_element_selected(session, element.id)
     assert_success(result, False)
     assert_dialog_handled(session, "dismiss #3")
 
 
 def test_handle_prompt_missing_value(session):
     # 13.1 step 2
     session.url = inline("<input id=foo>")
     element = session.find.css("#foo", all=False)
 
     create_dialog(session)("alert", text="dismiss #1", result_var="dismiss1")
 
-    result = session.transport.send("GET", "session/{session_id}/element/{element_id}/selected"
-                                    .format(session_id=session.session_id,
-                                            element_id=element.id))
-
+    result = is_element_selected(session, element.id)
     assert_error(result, "unexpected alert open")
     assert_dialog_handled(session, "dismiss #1")
 
     create_dialog(session)("confirm", text="dismiss #2", result_var="dismiss2")
 
-    result = session.transport.send("GET", "session/{session_id}/element/{element_id}/selected"
-                                    .format(session_id=session.session_id,
-                                            element_id=element.id))
-
+    result = is_element_selected(session, element.id)
     assert_error(result, "unexpected alert open")
     assert_dialog_handled(session, "dismiss #2")
 
     create_dialog(session)("prompt", text="dismiss #3", result_var="dismiss3")
 
-    result = session.transport.send("GET", "session/{session_id}/element/{element_id}/selected"
-                                    .format(session_id=session.session_id,
-                                            element_id=element.id))
-
+    result = is_element_selected(session, element.id)
     assert_error(result, "unexpected alert open")
     assert_dialog_handled(session, "dismiss #3")
 
 
 def test_element_stale(session):
     # 13.1 step 4
     session.url = check_doc
     element = session.find.css("#checked", all=False)
     session.refresh()
-    result = session.transport.send("GET", "session/{session_id}/element/{element_id}/selected"
-                                    .format(session_id=session.session_id,
-                                            element_id=element.id))
 
+    result = is_element_selected(session, element.id)
     assert_error(result, "stale element reference")
 
 
 def test_element_checked(session):
     # 13.1 step 5
     session.url = check_doc
     element = session.find.css("#checked", all=False)
-    result = session.transport.send("GET", "session/{session_id}/element/{element_id}/selected"
-                                    .format(session_id=session.session_id,
-                                            element_id=element.id))
 
+    result = is_element_selected(session, element.id)
     assert_success(result, True)
 
 
 def test_checkbox_not_selected(session):
     # 13.1 step 5
     session.url = check_doc
     element = session.find.css("#notChecked", all=False)
-    result = session.transport.send("GET", "session/{session_id}/element/{element_id}/selected"
-                                    .format(session_id=session.session_id,
-                                            element_id=element.id))
 
+    result = is_element_selected(session, element.id)
     assert_success(result, False)
 
 
 def test_element_selected(session):
     # 13.1 step 5
     session.url = option_doc
     element = session.find.css("#selected", all=False)
-    result = session.transport.send("GET", "session/{session_id}/element/{element_id}/selected"
-                                    .format(session_id=session.session_id,
-                                            element_id=element.id))
 
+    result = is_element_selected(session, element.id)
     assert_success(result, True)
 
 
 def test_element_not_selected(session):
     # 13.1 step 5
     session.url = option_doc
     element = session.find.css("#notSelected", all=False)
-    result = session.transport.send("GET", "session/{session_id}/element/{element_id}/selected"
-                                    .format(session_id=session.session_id,
-                                            element_id=element.id))
 
+    result = is_element_selected(session, element.id)
     assert_success(result, False)
--- a/testing/web-platform/tests/webdriver/tests/maximize_window/maximize.py
+++ b/testing/web-platform/tests/webdriver/tests/maximize_window/maximize.py
@@ -4,17 +4,18 @@ from tests.support.asserts import assert
 from tests.support.fixtures import create_dialog
 from tests.support.inline import inline
 
 
 alert_doc = inline("<script>window.alert()</script>")
 
 
 def maximize(session):
-    return session.transport.send("POST", "session/%s/window/maximize" % session.session_id)
+    return session.transport.send(
+        "POST", "session/{session_id}/window/maximize".format(**vars(session)))
 
 
 def is_fullscreen(session):
     # At the time of writing, WebKit does not conform to the Fullscreen API specification.
     # Remove the prefixed fallback when https://bugs.webkit.org/show_bug.cgi?id=158125 is fixed.
     return session.execute_script("return !!(window.fullScreen || document.webkitIsFullScreen)")
 
 
--- a/testing/web-platform/tests/webdriver/tests/set_window_rect/set.py
+++ b/testing/web-platform/tests/webdriver/tests/set_window_rect/set.py
@@ -6,17 +6,19 @@ from tests.support.asserts import assert
 from tests.support.fixtures import create_dialog
 from tests.support.inline import inline
 
 
 alert_doc = inline("<script>window.alert()</script>")
 
 
 def set_window_rect(session, rect):
-    return session.transport.send("POST", "session/%s/window/rect" % session.session_id, rect)
+    return session.transport.send(
+        "POST", "session/{session_id}/window/rect".format(**vars(session)),
+        rect)
 
 def is_fullscreen(session):
     # At the time of writing, WebKit does not conform to the Fullscreen API specification.
     # Remove the prefixed fallback when https://bugs.webkit.org/show_bug.cgi?id=158125 is fixed.
     return session.execute_script("return !!(window.fullScreen || document.webkitIsFullScreen)")
 
 
 # 10.7.2 Set Window Rect
--- a/testing/web-platform/tests/webdriver/tests/switch_to_parent_frame/switch.py
+++ b/testing/web-platform/tests/webdriver/tests/switch_to_parent_frame/switch.py
@@ -1,18 +1,23 @@
 import pytest
 from webdriver import StaleElementReferenceException
 
+from tests.support.asserts import assert_success
 from tests.support.inline import inline, iframe
 
 
 def switch_to_parent_frame(session):
-    return session.transport.send("POST", "session/%s/frame/parent" % session.session_id)
+    return session.transport.send(
+        "POST", "session/{session_id}/frame/parent".format(**vars(session)))
 
 
 def test_stale_element_from_iframe(session):
     session.url = inline(iframe("<p>foo"))
     frame_element = session.find.css("iframe", all=False)
     session.switch_frame(frame_element)
     stale_element = session.find.css("p", all=False)
-    switch_to_parent_frame(session)
+
+    result = switch_to_parent_frame(session)
+    assert_success(result)
+
     with pytest.raises(StaleElementReferenceException):
         stale_element.text
--- a/testing/web-platform/tests/webdriver/tests/user_prompts/accept_alert.py
+++ b/testing/web-platform/tests/webdriver/tests/user_prompts/accept_alert.py
@@ -1,15 +1,15 @@
 from tests.support.asserts import assert_error, assert_success
 from tests.support.inline import inline
 
 
 def accept_alert(session):
-    return session.transport.send("POST", "session/{session_id}/alert/accept"
-                                  .format(session_id=session.session_id))
+    return session.transport.send(
+        "POST", "session/{session_id}/alert/accept".format(**vars(session)))
 
 
 # 18.2 Accept Alert
 
 def test_no_browsing_context(session, create_window):
     # 18.2 step 1
     session.window_handle = create_window()
     session.close()
--- a/testing/web-platform/tests/webdriver/tests/user_prompts/dismiss_alert.py
+++ b/testing/web-platform/tests/webdriver/tests/user_prompts/dismiss_alert.py
@@ -1,15 +1,15 @@
 from tests.support.asserts import assert_error, assert_success
 from tests.support.inline import inline
 
 
 def dismiss_alert(session):
-    return session.transport.send("POST", "session/{session_id}/alert/dismiss"
-                                  .format(session_id=session.session_id))
+    return session.transport.send(
+        "POST", "session/{session_id}/alert/dismiss".format(**vars(session)))
 
 
 # 18.1 Dismiss Alert
 
 def test_no_browsing_context(session, create_window):
     # 18.1 step 1
     session.window_handle = create_window()
     session.close()
--- a/testing/web-platform/tests/webdriver/tests/user_prompts/get_alert_text.py
+++ b/testing/web-platform/tests/webdriver/tests/user_prompts/get_alert_text.py
@@ -1,15 +1,15 @@
 from tests.support.asserts import assert_error, assert_success
 from tests.support.inline import inline
 
 
 def get_dialog_text(session):
-    return session.transport.send("GET", "session/{session_id}/alert/text"
-                                  .format(session_id=session.session_id))
+    return session.transport.send(
+        "GET", "session/{session_id}/alert/text".format(**vars(session)))
 
 
 # 18.3 Get Alert Text
 
 def test_no_browsing_context(session, create_window):
     # 18.3 step 1
     session.window_handle = create_window()
     session.close()
--- a/testing/web-platform/tests/webdriver/tests/user_prompts/send_alert_text.py
+++ b/testing/web-platform/tests/webdriver/tests/user_prompts/send_alert_text.py
@@ -1,16 +1,17 @@
 import pytest
 
 from tests.support.asserts import assert_error, assert_success
 from tests.support.inline import inline
 
 def send_alert_text(session, body=None):
-    return session.transport.send("POST", "session/{session_id}/alert/text"
-                                  .format(session_id=session.session_id), body)
+    return session.transport.send(
+        "POST", "session/{session_id}/alert/text".format(**vars(session)),
+        body)
 
 
 # 18.4 Send Alert Text
 
 @pytest.mark.parametrize("text", [None, {}, [], 42, True])
 def test_invalid_input(session, text):
     # 18.4 step 2
     session.url = inline("<script>window.result = window.prompt('Enter Your Name: ', 'Name');</script>")