Bug 1455568 - [wdspec] Use shared command function for each WebDriver command. draft
authorHenrik Skupin <mail@hskupin.info>
Tue, 24 Apr 2018 18:57:48 +0200
changeset 792546 91ef9aae32eb1e07de7c9dd7d8f51de0080e5ccc
parent 792391 a41eba4d76259bd54fec7d9b420beb4173dd9660
child 792547 ac089a3e29875bc29ed71d2c7455f93558f7b694
push id109134
push userbmo:hskupin@gmail.com
push dateTue, 08 May 2018 15:13:37 +0000
bugs1455568
milestone61.0a1
Bug 1455568 - [wdspec] Use shared command function for each WebDriver command. Tests for a specific command have to use a shared function for each of the included tests of a module to avoid redefinition of the same code. In a follow-up patch those shared methods could even be separated out as fixtures for each of the sub folders. MozReview-Commit-ID: 11lAp7J8IoZ
testing/web-platform/tests/webdriver/tests/accept_alert/accept.py
testing/web-platform/tests/webdriver/tests/close_window/close.py
testing/web-platform/tests/webdriver/tests/close_window/user_prompts.py
testing/web-platform/tests/webdriver/tests/dismiss_alert/dismiss.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_async_script/user_prompts.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/execute_script/json_serialize_windowproxy.py
testing/web-platform/tests/webdriver/tests/execute_script/user_prompts.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_alert_text/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_timeouts/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/minimize_window/minimize.py
testing/web-platform/tests/webdriver/tests/page_source/source.py
testing/web-platform/tests/webdriver/tests/send_alert_text/send.py
testing/web-platform/tests/webdriver/tests/set_window_rect/set.py
testing/web-platform/tests/webdriver/tests/status/status.py
testing/web-platform/tests/webdriver/tests/switch_to_parent_frame/switch.py
--- a/testing/web-platform/tests/webdriver/tests/accept_alert/accept.py
+++ b/testing/web-platform/tests/webdriver/tests/accept_alert/accept.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/close_window/close.py
+++ b/testing/web-platform/tests/webdriver/tests/close_window/close.py
@@ -1,13 +1,14 @@
 from tests.support.asserts import assert_error, assert_success
 
 
 def close(session):
-    return session.transport.send("DELETE", "session/%s/window" % session.session_id)
+    return session.transport.send(
+        "DELETE", "session/{session_id}/window".format(**vars(session)))
 
 
 def test_no_browsing_context(session, create_window):
     new_handle = create_window()
 
     session.window_handle = new_handle
     session.close()
     assert new_handle not in session.handles
--- a/testing/web-platform/tests/webdriver/tests/close_window/user_prompts.py
+++ b/testing/web-platform/tests/webdriver/tests/close_window/user_prompts.py
@@ -1,17 +1,18 @@
 # META: timeout=long
 
 from tests.support.asserts import assert_error, assert_dialog_handled
 from tests.support.fixtures import create_dialog, create_window
 from tests.support.inline import inline
 
 
 def close(session):
-    return session.transport.send("DELETE", "session/%s/window" % session.session_id)
+    return session.transport.send(
+        "DELETE", "session/{session_id}/window".format(**vars(session)))
 
 
 def test_handle_prompt_dismiss_and_notify():
     """TODO"""
 
 
 def test_handle_prompt_accept_and_notify():
     """TODO"""
--- a/testing/web-platform/tests/webdriver/tests/dismiss_alert/dismiss.py
+++ b/testing/web-platform/tests/webdriver/tests/dismiss_alert/dismiss.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/element_clear/clear.py
+++ b/testing/web-platform/tests/webdriver/tests/element_clear/clear.py
@@ -4,43 +4,48 @@ import pytest
 
 from tests.support.asserts import (
     assert_element_has_focus,
     assert_error,
     assert_success,
 )
 from tests.support.inline import inline
 
+
+def element_clear(session, element):
+    return session.transport.send(
+        "POST", "/session/{session_id}/element/{element_id}/clear".format(
+            session_id=session.session_id,
+            element_id=element.id))
+
+
 def add_event_listeners(element):
     element.session.execute_script("""
         var target = arguments[0];
         window.events = [];
         var expectedEvents = ["focus", "blur", "change"];
         for (var i = 0; i < expectedEvents.length; i++) {
-          target.addEventListener(expectedEvents[i], function (eventObject) { window.events.push(eventObject.type) });
+          target.addEventListener(expectedEvents[i], function (eventObject) {
+            window.events.push(eventObject.type)
+          });
         }
         """, args=(element,))
 
 
 def get_events(session):
     return session.execute_script("return window.events")
 
 
 @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))
-
-
 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()
 
     response = element_clear(session, element)
--- a/testing/web-platform/tests/webdriver/tests/element_click/bubbling.py
+++ b/testing/web-platform/tests/webdriver/tests/element_click/bubbling.py
@@ -1,13 +1,13 @@
 from tests.support.asserts import assert_success
 from tests.support.inline import inline
 
 
-def click(session, element):
+def element_click(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("""
@@ -149,10 +149,10 @@ def test_element_disappears_during_click
         over.addEventListener("mousedown", function(mousedownEvent) {
           over.style.display = "none";
         });
         </script>
         """)
     over = session.find.css("#over", all=False)
 
     # should not time out
-    response = click(session, over)
+    response = element_click(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
@@ -1,22 +1,18 @@
-import pytest
-import webdriver
-
 from tests.support.asserts import assert_error
 from tests.support.inline import inline
 
 
-def click_element(session, element):
+def element_click(session, element):
     return session.transport.send(
-        "POST", "/session/{session_id}/element/{element_id}/click".format(**{
-            "session_id": session.session_id,
-            "element_id": element.id,
-        }))
+        "POST", "/session/{session_id}/element/{element_id}/click".format(
+            session_id=session.session_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)
+    response = element_click(session, button)
     assert_error(response, "stale element reference")
--- 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):
+def element_send_keys(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">
@@ -19,17 +18,17 @@ def test_body_is_interactable(session):
     """)
 
     element = session.find.css("body", all=False)
     result = session.find.css("input", all=False)
 
     # By default body is the active element
     assert session.active_element is element
 
-    response = send_keys_to_element(session, element, "foo")
+    response = element_send_keys(session, element, "foo")
     assert_success(response)
     assert session.active_element is element
     assert result.property("value") == "foo"
 
 
 def test_document_element_is_interactable(session):
     session.url = inline("""
         <html onkeypress="document.querySelector('input').value += event.key">
@@ -39,17 +38,17 @@ def test_document_element_is_interactabl
 
     body = session.find.css("body", all=False)
     element = session.find.css(":root", all=False)
     result = session.find.css("input", all=False)
 
     # By default body is the active element
     assert session.active_element is body
 
-    response = send_keys_to_element(session, element, "foo")
+    response = element_send_keys(session, element, "foo")
     assert_success(response)
     assert session.active_element is element
     assert result.property("value") == "foo"
 
 
 def test_iframe_is_interactable(session):
     session.url = inline(iframe("""
         <body onkeypress="document.querySelector('input').value += event.key">
@@ -58,79 +57,79 @@ def test_iframe_is_interactable(session)
     """))
 
     body = session.find.css("body", all=False)
     frame = session.find.css("iframe", all=False)
 
     # By default the body has the focus
     assert session.active_element is body
 
-    response = send_keys_to_element(session, frame, "foo")
+    response = element_send_keys(session, frame, "foo")
     assert_success(response)
     assert session.active_element is frame
 
     # Any key events are immediately routed to the nested
     # browsing context's active document.
     session.switch_frame(frame)
     result = session.find.css("input", all=False)
     assert result.property("value") == "foo"
 
 
 def test_transparent_element(session):
     session.url = inline("""<input style="opacity: 0">""")
     element = session.find.css("input", all=False)
 
-    response = send_keys_to_element(session, element, "foo")
+    response = element_send_keys(session, element, "foo")
     assert_success(response)
     assert element.property("value") == "foo"
 
 
 def test_readonly_element(session):
     session.url = inline("<input readonly>")
     element = session.find.css("input", all=False)
 
-    response = send_keys_to_element(session, element, "foo")
+    response = element_send_keys(session, element, "foo")
     assert_success(response)
     assert element.property("value") == ""
 
 
 def test_obscured_element(session):
     session.url = inline("""
       <input>
       <div style="position: relative; top: -3em; height: 5em; background: blue;"></div>
     """)
     element = session.find.css("input", all=False)
 
-    response = send_keys_to_element(session, element, "foo")
+    response = element_send_keys(session, element, "foo")
     assert_success(response)
     assert element.property("value") == "foo"
 
 
 def test_not_a_focusable_element(session):
     session.url = inline("<div>foo</div>")
     element = session.find.css("div", all=False)
 
-    response = send_keys_to_element(session, element, "foo")
+    response = element_send_keys(session, element, "foo")
     assert_error(response, "element not interactable")
 
 
 def test_not_displayed_element(session):
     session.url = inline("""<input style="display: none">""")
     element = session.find.css("input", all=False)
 
-    response = send_keys_to_element(session, element, "foo")
+    response = element_send_keys(session, element, "foo")
     assert_error(response, "element not interactable")
 
 
 def test_hidden_element(session):
     session.url = inline("""<input style="visibility: hidden">""")
     element = session.find.css("input", all=False)
 
-    response = send_keys_to_element(session, element, "foo")
+    response = element_send_keys(session, element, "foo")
     assert_error(response, "element not interactable")
 
 
 def test_disabled_element(session):
     session.url = inline("""<input disabled>""")
     element = session.find.css("input", all=False)
 
-    response = send_keys_to_element(session, element, "foo")
+    response = element_send_keys(session, element, "foo")
     assert_error(response, "element not interactable")
--- 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,53 +1,52 @@
 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):
+def element_send_keys(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)
 
-    response = send_keys_to_element(session, element, "foo")
+    response = element_send_keys(session, element, "foo")
     assert_success(response)
 
     assert not is_element_in_viewport(session, element)
 
 
 def test_element_outside_of_scrollable_viewport(session):
     session.url = inline("<input style=\"margin-top: 102vh;\">")
     element = session.find.css("input", all=False)
 
-    response = send_keys_to_element(session, element, "foo")
+    response = element_send_keys(session, element, "foo")
     assert_success(response)
 
     assert is_element_in_viewport(session, element)
 
 
 def test_option_select_container_outside_of_scrollable_viewport(session):
     session.url = inline("""
         <select style="margin-top: 102vh;">
           <option value="foo">foo</option>
           <option value="bar" id="bar">bar</option>
         </select>
     """)
     element = session.find.css("option#bar", all=False)
     select = session.find.css("select", all=False)
 
-    response = send_keys_to_element(session, element, "bar")
+    response = element_send_keys(session, element, "bar")
     assert_success(response)
 
     assert is_element_in_viewport(session, select)
     assert is_element_in_viewport(session, element)
 
 
 def test_option_stays_outside_of_scrollable_viewport(session):
     session.url = inline("""
@@ -55,24 +54,24 @@ def test_option_stays_outside_of_scrolla
           <option value="foo" id="foo" style="height: 100vh;">foo</option>
           <option value="bar" id="bar" style="background-color: yellow;">bar</option>
         </select>
     """)
     select = session.find.css("select", all=False)
     option_foo = session.find.css("option#foo", all=False)
     option_bar = session.find.css("option#bar", all=False)
 
-    response = send_keys_to_element(session, option_bar, "bar")
+    response = element_send_keys(session, option_bar, "bar")
     assert_success(response)
 
     assert is_element_in_viewport(session, select)
     assert is_element_in_viewport(session, option_foo)
     assert not is_element_in_viewport(session, option_bar)
 
 
 def test_contenteditable_element_outside_of_scrollable_viewport(session):
     session.url = inline("<div contenteditable style=\"margin-top: 102vh;\"></div>")
     element = session.find.css("div", all=False)
 
-    response = send_keys_to_element(session, element, "foo")
+    response = element_send_keys(session, element, "foo")
     assert_success(response)
 
     assert is_element_in_viewport(session, element)
--- a/testing/web-platform/tests/webdriver/tests/execute_async_script/collections.py
+++ b/testing/web-platform/tests/webdriver/tests/execute_async_script/collections.py
@@ -3,19 +3,19 @@ import os
 from tests.support.asserts import assert_same_element, assert_success
 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_async_script/user_prompts.py
+++ b/testing/web-platform/tests/webdriver/tests/execute_async_script/user_prompts.py
@@ -1,74 +1,98 @@
 import pytest
 
 from webdriver import error
 
+from tests.support.asserts import assert_success
 
-# 15.2 Executing Script
+
+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)),
+        body)
+
 
 def test_handle_prompt_accept(new_session, add_browser_capabilites):
     _, session = new_session({"capabilities": {"alwaysMatch": add_browser_capabilites({"unhandledPromptBehavior": "accept"})}})
-    value = session.execute_async_script("window.alert('Hello');")
-    assert value is None
-    title = session.title
+
+    response = execute_async_script(session, "window.alert('Hello');")
+    assert_success(response, None)
+
+    session.title
     with pytest.raises(error.NoSuchAlertException):
         session.alert.accept()
 
 
 def test_handle_prompt_dismiss(new_session, add_browser_capabilites):
     _, session = new_session({"capabilities": {"alwaysMatch": add_browser_capabilites({"unhandledPromptBehavior": "dismiss"})}})
-    value = session.execute_async_script("window.alert('Hello');")
-    assert value is None
-    title = session.title
+
+    response = execute_async_script(session, "window.alert('Hello');")
+    assert_success(response, None)
+
+    session.title
     with pytest.raises(error.NoSuchAlertException):
         session.alert.dismiss()
 
 
 def test_handle_prompt_dismiss_and_notify(new_session, add_browser_capabilites):
     _, session = new_session({"capabilities": {"alwaysMatch": add_browser_capabilites({"unhandledPromptBehavior": "dismiss and notify"})}})
-    value = session.execute_async_script("window.alert('Hello');")
-    assert value is None
+
+    response = execute_async_script(session, "window.alert('Hello');")
+    assert_success(response, None)
+
     with pytest.raises(error.UnexpectedAlertOpenException):
-        title = session.title
+        session.title
     with pytest.raises(error.NoSuchAlertException):
         session.alert.dismiss()
 
 
 def test_handle_prompt_accept_and_notify(new_session, add_browser_capabilites):
     _, session = new_session({"capabilities": {"alwaysMatch": add_browser_capabilites({"unhandledPromptBehavior": "accept and notify"})}})
-    value = session.execute_async_script("window.alert('Hello');")
-    assert value is None
+
+    response = execute_async_script(session, "window.alert('Hello');")
+    assert_success(response, None)
+
     with pytest.raises(error.UnexpectedAlertOpenException):
-        title = session.title
+        session.title
     with pytest.raises(error.NoSuchAlertException):
         session.alert.accept()
 
 
 def test_handle_prompt_ignore(new_session, add_browser_capabilites):
     _, session = new_session({"capabilities": {"alwaysMatch": add_browser_capabilites({"unhandledPromptBehavior": "ignore"})}})
-    value = session.execute_async_script("window.alert('Hello');")
-    assert value is None
+
+    response = execute_async_script(session, "window.alert('Hello');")
+    assert_success(response, None)
+
     with pytest.raises(error.UnexpectedAlertOpenException):
-        title = session.title
+        session.title
     session.alert.dismiss()
 
 
 def test_handle_prompt_default(new_session, add_browser_capabilites):
     _, session = new_session({"capabilities": {"alwaysMatch": add_browser_capabilites({})}})
-    value = session.execute_async_script("window.alert('Hello');")
-    assert value is None
+
+    response = execute_async_script(session, "window.alert('Hello');")
+    assert_success(response, None)
+
     with pytest.raises(error.UnexpectedAlertOpenException):
-        title = session.title
+        session.title
     with pytest.raises(error.NoSuchAlertException):
         session.alert.dismiss()
 
 
 def test_handle_prompt_twice(new_session, add_browser_capabilites):
     _, session = new_session({"capabilities": {"alwaysMatch": add_browser_capabilites({"unhandledPromptBehavior": "accept"})}})
-    value = session.execute_async_script("window.alert('Hello');window.alert('Bye');")
-    assert value is None
+
+    response = execute_async_script(session, "window.alert('Hello');window.alert('Bye');")
+    assert_success(response, None)
+
     session.alert.dismiss()
     # The first alert has been accepted by the user prompt handler, the second one remains.
     # FIXME: this is how browsers currently work, but the spec should clarify if this is the
     #        expected behavior, see https://github.com/w3c/webdriver/issues/1153.
     assert session.alert.text == "Bye"
     session.alert.dismiss()
--- a/testing/web-platform/tests/webdriver/tests/execute_script/collections.py
+++ b/testing/web-platform/tests/webdriver/tests/execute_script/collections.py
@@ -3,19 +3,19 @@ import os
 from tests.support.asserts import assert_same_element, assert_success
 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,18 @@
 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/execute_script/json_serialize_windowproxy.py
+++ b/testing/web-platform/tests/webdriver/tests/execute_script/json_serialize_windowproxy.py
@@ -1,42 +1,63 @@
 # META: timeout=long
 
 import json
 
+from tests.support.asserts import assert_success
+
 
 _window_id = "window-fcc6-11e5-b4f8-330a88ab9d7f"
 _frame_id = "frame-075b-4da1-b6ba-e579c2d3230a"
 
+
+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)),
+        body)
+
+
 def test_initial_window(session):
     # non-auxiliary top-level browsing context
-    raw_json = session.execute_script("return window;")
+    response = execute_script(session, "return window;")
+    raw_json = assert_success(response)
+
     obj = json.loads(raw_json)
     assert len(obj) == 1
     assert _window_id in obj
     handle = obj[_window_id]
     assert handle in session.window_handles
 
 
 def test_window_open(session):
     # auxiliary browsing context
     session.execute_script("window.foo = window.open()")
-    raw_json = session.execute_script("return window.foo;")
+
+    response = execute_script(session, "return window.foo;")
+    raw_json = assert_success(response)
+
     obj = json.loads(raw_json)
     assert len(obj) == 1
     assert _window_id in obj
     handle = obj[_window_id]
     assert handle in session.window_handles
 
 
 def test_frame(session):
     # nested browsing context
     append = """
         window.frame = document.createElement('iframe');
         document.body.appendChild(frame);
     """
     session.execute_script(append)
-    raw_json = session.execute_script("return frame.contentWindow;")
+
+    response = execute_script(session, "return frame.contentWindow;")
+    raw_json = assert_success(response)
+
     obj = json.loads(raw_json)
     assert len(obj) == 1
     assert _frame_id in obj
     handle = obj[_frame_id]
     assert handle not in session.window_handles
--- a/testing/web-platform/tests/webdriver/tests/execute_script/user_prompts.py
+++ b/testing/web-platform/tests/webdriver/tests/execute_script/user_prompts.py
@@ -1,74 +1,99 @@
 import pytest
 
 from webdriver import error
 
+from tests.support.asserts import assert_success
 
-# 15.2 Executing Script
+
+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(
+            session_id=session.session_id),
+        body)
+
 
 def test_handle_prompt_accept(new_session, add_browser_capabilites):
     _, session = new_session({"capabilities": {"alwaysMatch": add_browser_capabilites({"unhandledPromptBehavior": "accept"})}})
-    value = session.execute_script("window.alert('Hello');")
-    assert value is None
-    title = session.title
+
+    response = execute_script(session, "window.alert('Hello');")
+    assert_success(response, None)
+
+    session.title
     with pytest.raises(error.NoSuchAlertException):
         session.alert.accept()
 
 
 def test_handle_prompt_dismiss(new_session, add_browser_capabilites):
     _, session = new_session({"capabilities": {"alwaysMatch": add_browser_capabilites({"unhandledPromptBehavior": "dismiss"})}})
-    value = session.execute_script("window.alert('Hello');")
-    assert value is None
-    title = session.title
+
+    response = execute_script(session, "window.alert('Hello');")
+    assert_success(response, None)
+
+    session.title
     with pytest.raises(error.NoSuchAlertException):
         session.alert.dismiss()
 
 
 def test_handle_prompt_dismiss_and_notify(new_session, add_browser_capabilites):
     _, session = new_session({"capabilities": {"alwaysMatch": add_browser_capabilites({"unhandledPromptBehavior": "dismiss and notify"})}})
-    value = session.execute_script("window.alert('Hello');")
-    assert value is None
+
+    response = execute_script(session, "window.alert('Hello');")
+    assert_success(response, None)
+
     with pytest.raises(error.UnexpectedAlertOpenException):
-        title = session.title
+        session.title
     with pytest.raises(error.NoSuchAlertException):
         session.alert.dismiss()
 
 
 def test_handle_prompt_accept_and_notify(new_session, add_browser_capabilites):
     _, session = new_session({"capabilities": {"alwaysMatch": add_browser_capabilites({"unhandledPromptBehavior": "accept and notify"})}})
-    value = session.execute_script("window.alert('Hello');")
-    assert value is None
+
+    response = execute_script(session, "window.alert('Hello');")
+    assert_success(response, None)
+
     with pytest.raises(error.UnexpectedAlertOpenException):
-        title = session.title
+        session.title
     with pytest.raises(error.NoSuchAlertException):
         session.alert.accept()
 
 
 def test_handle_prompt_ignore(new_session, add_browser_capabilites):
     _, session = new_session({"capabilities": {"alwaysMatch": add_browser_capabilites({"unhandledPromptBehavior": "ignore"})}})
-    value = session.execute_script("window.alert('Hello');")
-    assert value is None
+
+    response = execute_script(session, "window.alert('Hello');")
+    assert_success(response, None)
+
     with pytest.raises(error.UnexpectedAlertOpenException):
-        title = session.title
+        session.title
     session.alert.dismiss()
 
 
 def test_handle_prompt_default(new_session, add_browser_capabilites):
     _, session = new_session({"capabilities": {"alwaysMatch": add_browser_capabilites({})}})
-    value = session.execute_script("window.alert('Hello');")
-    assert value is None
+
+    response = execute_script(session, "window.alert('Hello');")
+    assert_success(response, None)
+
     with pytest.raises(error.UnexpectedAlertOpenException):
-        title = session.title
+        session.title
     with pytest.raises(error.NoSuchAlertException):
         session.alert.dismiss()
 
 
 def test_handle_prompt_twice(new_session, add_browser_capabilites):
     _, session = new_session({"capabilities": {"alwaysMatch": add_browser_capabilites({"unhandledPromptBehavior": "accept"})}})
-    value = session.execute_script("window.alert('Hello');window.alert('Bye');")
-    assert value is None
+
+    response = execute_script(session, "window.alert('Hello');window.alert('Bye');")
+    assert_success(response, None)
+
     session.alert.dismiss()
     # The first alert has been accepted by the user prompt handler, the second one remains.
     # FIXME: this is how browsers currently work, but the spec should clarify if this is the
     #        expected behavior, see https://github.com/w3c/webdriver/issues/1153.
     assert session.alert.text == "Bye"
     session.alert.dismiss()
--- 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,21 @@
 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_alert_text/get.py
+++ b/testing/web-platform/tests/webdriver/tests/get_alert_text/get.py
@@ -1,60 +1,60 @@
 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))
+def get_alert_text(session):
+    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()
 
-    response = get_dialog_text(session)
+    response = get_alert_text(session)
     assert_error(response, "no such window")
 
 
 def test_no_user_prompt(session):
     # 18.3 step 2
-    response = get_dialog_text(session)
+    response = get_alert_text(session)
     assert_error(response, "no such alert")
 
 
 def test_get_alert_text(session):
     # 18.3 step 3
     session.url = inline("<script>window.alert('Hello');</script>")
-    response = get_dialog_text(session)
+    response = get_alert_text(session)
     assert_success(response)
     assert isinstance(response.body, dict)
     assert "value" in response.body
     alert_text = response.body["value"]
     assert isinstance(alert_text, basestring)
     assert alert_text == "Hello"
 
 
 def test_get_confirm_text(session):
     # 18.3 step 3
     session.url = inline("<script>window.confirm('Hello');</script>")
-    response = get_dialog_text(session)
+    response = get_alert_text(session)
     assert_success(response)
     assert isinstance(response.body, dict)
     assert "value" in response.body
     confirm_text = response.body["value"]
     assert isinstance(confirm_text, basestring)
     assert confirm_text == "Hello"
 
 
 def test_get_prompt_text(session):
     # 18.3 step 3
     session.url = inline("<script>window.prompt('Enter Your Name: ', 'Federer');</script>")
-    response = get_dialog_text(session)
+    response = get_alert_text(session)
     assert_success(response)
     assert isinstance(response.body, dict)
     assert "value" in response.body
     prompt_text = response.body["value"]
     assert isinstance(prompt_text, basestring)
     assert prompt_text == "Enter Your Name: "
--- 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,102 @@ 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
@@ -2,167 +2,135 @@
 
 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
 
 _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
@@ -1,151 +1,120 @@
 # META: timeout=long
 
 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_timeouts/get.py
+++ b/testing/web-platform/tests/webdriver/tests/get_timeouts/get.py
@@ -1,18 +1,16 @@
 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(**vars(session)))
 
 
-# 8.4 Get Timeouts
-
 def test_get_timeouts(session):
     # 8.4 step 1
     response = get_timeouts(session)
 
     assert_success(response)
     assert "value" in response.body
     assert isinstance(response.body["value"], dict)
 
--- 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,20 +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)
-
-
-# 10.7.1 Get Window Rect
+    return session.transport.send(
+        "GET", "session/{session_id}/window/rect".format(**vars(session)))
 
 
 def test_no_browsing_context(session, create_window):
     """
     1. If the current top-level browsing context is no longer open,
     return error with error code no such window.
 
     """
--- a/testing/web-platform/tests/webdriver/tests/is_element_selected/selected.py
+++ b/testing/web-platform/tests/webdriver/tests/is_element_selected/selected.py
@@ -9,177 +9,142 @@ alert_doc = inline("<script>window.alert
 check_doc = inline("<input id=checked type=checkbox checked/><input id=notChecked type=checkbox/>")
 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/minimize_window/minimize.py
+++ b/testing/web-platform/tests/webdriver/tests/minimize_window/minimize.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 minimize(session):
-    return session.transport.send("POST", "session/%s/window/minimize" % session.session_id)
+    return session.transport.send(
+        "POST", "session/{session_id}/window/minimize".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)")
 
 # 10.7.4 Minimize Window
--- a/testing/web-platform/tests/webdriver/tests/page_source/source.py
+++ b/testing/web-platform/tests/webdriver/tests/page_source/source.py
@@ -1,14 +1,16 @@
-import pytest
-
+from tests.support.asserts import assert_success
 from tests.support.inline import inline
 
 
-# 15.1.3 "Let source be the result returned from the outerHTML IDL attribute
-#         of the document element"
+def get_page_source(session):
+    return session.transport.send(
+        "GET", "session/{session_id}/source".format(**vars(session)))
+
+
 def test_source_matches_outer_html(session):
     session.url = inline("<html><head><title>Cheese</title><body>Peas")
-    expected_source = session.execute_script(
-        "return document.documentElement.outerHTML")
+
+    expected = session.execute_script("return document.documentElement.outerHTML")
 
-    assert session.source == expected_source
-
+    response = get_page_source(session)
+    assert_success(response, expected)
--- a/testing/web-platform/tests/webdriver/tests/send_alert_text/send.py
+++ b/testing/web-platform/tests/webdriver/tests/send_alert_text/send.py
@@ -1,16 +1,18 @@
 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>")
--- 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,20 @@ 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/status/status.py
+++ b/testing/web-platform/tests/webdriver/tests/status/status.py
@@ -1,11 +1,16 @@
-import pytest
 import json
 
+from tests.support.asserts import assert_success
+
+
+def get_status(session):
+    return session.transport.send("GET", "/status")
+
 
 def test_get_status_no_session(http):
     with http.get("/status") as response:
         # GET /status should never return an error
         assert response.status == 200
 
         # parse JSON response and unwrap 'value' property
         parsed_obj = json.loads(response.read().decode('utf-8'))
@@ -23,23 +28,23 @@ def test_get_status_no_session(http):
 
 def test_status_with_session_running_on_endpoint_node(new_session, add_browser_capabilites):
     # For an endpoint node, the maximum number of active
     # sessions is 1: https://www.w3.org/TR/webdriver/#dfn-maximum-active-sessions
     # A session is open, so we expect `ready` to be False
     # 8.3 step 1.
 
     _, session = new_session({"capabilities": {"alwaysMatch": add_browser_capabilites({})}})
-    value = session.send_command("GET", "status")
 
-    assert value["ready"] == False
+    response = get_status(session)
+    value = assert_success(response)
+    assert value["ready"] is False
     assert "message" in value
 
     session.end()
 
     # Active session count is 0, meaning that the
     # readiness state of the server should be True
     # 8.3 step 1. Again
-    value = session.send_command("GET", "status")
-
-    assert value["ready"] == True
+    response = get_status(session)
+    value = assert_success(response)
+    assert value["ready"] is True
     assert "message" in value
-
--- 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