bug 1585964: webdriver: drop regex dependency; r=webdriver-reviewers,jgraham
authorAndreas Tolfsen <ato@sny.no>
Mon, 07 Oct 2019 12:53:38 +0000
changeset 497336 0cf9f22a8c4d84e70f6c6e9006fb9f3d844e53aa
parent 497335 1c6ab26ee4cf9b1cc437efaa672b43966e15a187
child 497337 becf56f3cc37db3fc96b4689ac3afe70987b614a
push id36682
push userncsoregi@mozilla.com
push dateSat, 12 Oct 2019 09:52:03 +0000
treeherdermozilla-central@06ea2371f897 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswebdriver-reviewers, jgraham
bugs1585964
milestone71.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
bug 1585964: webdriver: drop regex dependency; r=webdriver-reviewers,jgraham webdriver depends on the regex crate for unit testing which adds significant overhead building the crate. We could depend on serde_json::from_value() instead, following the same pattern set forth in the marionette crate. Differential Revision: https://phabricator.services.mozilla.com/D48318
Cargo.lock
testing/webdriver/Cargo.toml
testing/webdriver/src/actions.rs
testing/webdriver/src/capabilities.rs
testing/webdriver/src/command.rs
testing/webdriver/src/common.rs
testing/webdriver/src/error.rs
testing/webdriver/src/lib.rs
testing/webdriver/src/response.rs
testing/webdriver/src/test.rs
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -3516,19 +3516,17 @@ source = "registry+https://github.com/ru
 
 [[package]]
 name = "webdriver"
 version = "0.40.2"
 dependencies = [
  "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "cookie 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)",
- "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
- "regex 1.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde 1.0.88 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde_derive 1.0.88 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde_json 1.0.26 (registry+https://github.com/rust-lang/crates.io-index)",
  "time 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
  "tokio 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
  "unicode-segmentation 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "url 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "warp 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)",
--- a/testing/webdriver/Cargo.toml
+++ b/testing/webdriver/Cargo.toml
@@ -9,20 +9,16 @@ repository = "https://hg.mozilla.org/moz
 readme = "README.md"
 license = "MPL-2.0"
 
 [dependencies]
 base64 = "0.10"
 cookie = { version = "0.12", default-features = false }
 http = "0.1"
 log = "0.4"
-regex = "1.0"
 serde = "1.0"
 serde_json = "1.0"
 serde_derive = "1.0"
 time = "0.1"
 tokio = "0.1"
 unicode-segmentation = "1.2"
 url = "2.0"
 warp = { version = "0.1", default-features = false }
-
-[dev-dependencies]
-lazy_static = "1.0"
--- a/testing/webdriver/src/actions.rs
+++ b/testing/webdriver/src/actions.rs
@@ -235,76 +235,77 @@ where
 {
     Option::deserialize(deserializer)?
         .ok_or_else(|| de::Error::custom("invalid type: null, expected i64"))
 }
 
 #[cfg(test)]
 mod test {
     use super::*;
-    use crate::test::{check_deserialize, check_serialize_deserialize};
-    use serde_json;
+    use crate::test::{assert_de, assert_ser_de};
+    use serde_json::{self, json};
 
     #[test]
     fn test_json_action_sequence_null() {
-        let json = r#"{
-            "id":"some_key",
-            "type":"none",
-            "actions":[{
-                "type":"pause","duration":1
+        let json = json!({
+            "id": "some_key",
+            "type": "none",
+            "actions": [{
+                "type": "pause",
+                "duration": 1,
             }]
-        }"#;
-        let data = ActionSequence {
+        });
+        let seq = ActionSequence {
             id: "some_key".into(),
             actions: ActionsType::Null {
                 actions: vec![NullActionItem::General(GeneralAction::Pause(PauseAction {
                     duration: Some(1),
                 }))],
             },
         };
 
-        check_serialize_deserialize(&json, &data);
+        assert_ser_de(&seq, json);
     }
 
     #[test]
     fn test_json_action_sequence_key() {
-        let json = r#"{
-            "id":"some_key",
-            "type":"key",
-            "actions":[
-                {"type":"keyDown","value":"f"}
-            ]
-        }"#;
-        let data = ActionSequence {
+        let json = json!({
+            "id": "some_key",
+            "type": "key",
+            "actions": [
+                {"type": "keyDown", "value": "f"},
+            ],
+        });
+        let seq = ActionSequence {
             id: "some_key".into(),
             actions: ActionsType::Key {
                 actions: vec![KeyActionItem::Key(KeyAction::Down(KeyDownAction {
                     value: String::from("f"),
                 }))],
             },
         };
 
-        check_serialize_deserialize(&json, &data);
+        assert_ser_de(&seq, json);
     }
 
     #[test]
     fn test_json_action_sequence_pointer() {
-        let json = r#"{
-            "id":"some_pointer",
-            "type":"pointer",
-            "parameters":{
-                "pointerType":"mouse"
+        let json = json!({
+            "id": "some_pointer",
+            "type": "pointer",
+            "parameters": {
+                "pointerType": "mouse"
             },
-            "actions":[
-                {"type":"pointerDown","button":0},
-                {"type":"pointerMove","origin":"pointer","x":10,"y":20},
-                {"type":"pointerUp","button":0}
+            "actions": [
+                {"type": "pointerDown", "button": 0},
+                {"type": "pointerMove", "origin": "pointer", "x": 10, "y": 20},
+                {"type": "pointerUp", "button": 0},
             ]
-        }"#;
-        let data = ActionSequence {
+        });
+        let seq = ActionSequence {
             id: "some_pointer".into(),
             actions: ActionsType::Pointer {
                 parameters: PointerActionParameters {
                     pointer_type: PointerType::Mouse,
                 },
                 actions: vec![
                     PointerActionItem::Pointer(PointerAction::Down(PointerDownAction {
                         button: 0,
@@ -315,867 +316,741 @@ mod test {
                         x: Some(10),
                         y: Some(20),
                     })),
                     PointerActionItem::Pointer(PointerAction::Up(PointerUpAction { button: 0 })),
                 ],
             },
         };
 
-        check_serialize_deserialize(&json, &data);
+        assert_ser_de(&seq, json);
     }
 
     #[test]
     fn test_json_action_sequence_id_missing() {
-        let json = r#"{
+        let json = json!({
             "type": "key",
-            "actions": []
-        }"#;
-
-        assert!(serde_json::from_str::<ActionSequence>(&json).is_err());
+            "actions": [],
+        });
+        assert!(serde_json::from_value::<ActionSequence>(json).is_err());
     }
 
     #[test]
     fn test_json_action_sequence_id_null() {
-        let json = r#"{
+        let json = json!({
             "id": null,
             "type": "key",
-            "actions": []
-        }"#;
-
-        assert!(serde_json::from_str::<ActionSequence>(&json).is_err());
+            "actions": [],
+        });
+        assert!(serde_json::from_value::<ActionSequence>(json).is_err());
     }
 
     #[test]
     fn test_json_action_sequence_actions_missing() {
-        let json = r#"{
-            "id": "3"
-        }"#;
-
-        assert!(serde_json::from_str::<ActionSequence>(&json).is_err());
+        assert!(serde_json::from_value::<ActionSequence>(json!({"id": "3"})).is_err());
     }
 
     #[test]
     fn test_json_action_sequence_actions_null() {
-        let json = r#"{
+        let json = json!({
             "id": "3",
-            "actions": null
-        }"#;
-
-        assert!(serde_json::from_str::<ActionSequence>(&json).is_err());
+            "actions": null,
+        });
+        assert!(serde_json::from_value::<ActionSequence>(json).is_err());
     }
 
     #[test]
     fn test_json_action_sequence_actions_invalid_type() {
-        let json = r#"{
+        let json = json!({
             "id": "3",
-            "actions": "foo"
-        }"#;
-
-        assert!(serde_json::from_str::<ActionSequence>(&json).is_err());
+            "actions": "foo",
+        });
+        assert!(serde_json::from_value::<ActionSequence>(json).is_err());
     }
 
     #[test]
     fn test_json_actions_type_null() {
-        let json = r#"{
-            "type":"none",
-            "actions":[{
-                "type":"pause",
-                "duration":1
-            }]
-        }"#;
-        let data = ActionsType::Null {
+        let json = json!({
+            "type": "none",
+            "actions": [{
+                "type": "pause",
+                "duration": 1,
+            }],
+        });
+        let null = ActionsType::Null {
             actions: vec![NullActionItem::General(GeneralAction::Pause(PauseAction {
                 duration: Some(1),
             }))],
         };
 
-        check_serialize_deserialize(&json, &data);
+        assert_ser_de(&null, json);
     }
 
     #[test]
     fn test_json_actions_type_key() {
-        let json = r#"{
-            "type":"key",
-            "actions":[{
-                "type":"keyDown",
-                "value":"f"
-            }]
-        }"#;
-        let data = ActionsType::Key {
+        let json = json!({
+            "type": "key",
+            "actions": [{
+                "type": "keyDown",
+                "value": "f",
+            }],
+        });
+        let key = ActionsType::Key {
             actions: vec![KeyActionItem::Key(KeyAction::Down(KeyDownAction {
                 value: String::from("f"),
             }))],
         };
 
-        check_serialize_deserialize(&json, &data);
+        assert_ser_de(&key, json);
     }
 
     #[test]
     fn test_json_actions_type_pointer() {
-        let json = r#"{
-            "type":"pointer",
-            "parameters":{"pointerType":"mouse"},
-            "actions":[
-                {"type":"pointerDown","button":1}
-            ]}"#;
-        let data = ActionsType::Pointer {
+        let json = json!({
+        "type": "pointer",
+        "parameters": {"pointerType": "mouse"},
+        "actions": [
+            {"type": "pointerDown", "button": 1},
+        ]});
+        let pointer = ActionsType::Pointer {
             parameters: PointerActionParameters {
                 pointer_type: PointerType::Mouse,
             },
             actions: vec![PointerActionItem::Pointer(PointerAction::Down(
                 PointerDownAction { button: 1 },
             ))],
         };
 
-        check_serialize_deserialize(&json, &data);
+        assert_ser_de(&pointer, json);
     }
 
     #[test]
     fn test_json_actions_type_pointer_with_parameters_missing() {
-        let json = r#"{
-            "type":"pointer",
-            "actions":[
-                {"type":"pointerDown","button":1}
-            ]}"#;
-        let data = ActionsType::Pointer {
+        let json = json!({
+        "type": "pointer",
+        "actions": [
+            {"type": "pointerDown", "button": 1},
+        ]});
+        let pointer = ActionsType::Pointer {
             parameters: PointerActionParameters {
                 pointer_type: PointerType::Mouse,
             },
             actions: vec![PointerActionItem::Pointer(PointerAction::Down(
                 PointerDownAction { button: 1 },
             ))],
         };
 
-        check_deserialize(&json, &data);
+        assert_de(&pointer, json);
     }
 
     #[test]
     fn test_json_actions_type_pointer_with_parameters_invalid_type() {
-        let json = r#"{
-            "type":"pointer",
-            "parameters":null,
-            "actions":[
-                {"type":"pointerDown","button":1}
-            ]}"#;
-
-        assert!(serde_json::from_str::<ActionsType>(&json).is_err());
+        let json = json!({
+        "type": "pointer",
+        "parameters": null,
+        "actions": [
+            {"type":"pointerDown", "button": 1},
+        ]});
+        assert!(serde_json::from_value::<ActionsType>(json).is_err());
     }
 
     #[test]
     fn test_json_actions_type_invalid() {
-        let json = r#"{"actions":[{"foo":"bar"}]}"#;
-        assert!(serde_json::from_str::<ActionsType>(&json).is_err());
+        let json = json!({"actions": [{"foo": "bar"}]});
+        assert!(serde_json::from_value::<ActionsType>(json).is_err());
     }
 
     #[test]
     fn test_json_null_action_item_general() {
-        let json = r#"{"type":"pause","duration":1}"#;
-        let data = NullActionItem::General(GeneralAction::Pause(PauseAction { duration: Some(1) }));
-
-        check_serialize_deserialize(&json, &data);
+        let pause =
+            NullActionItem::General(GeneralAction::Pause(PauseAction { duration: Some(1) }));
+        assert_ser_de(&pause, json!({"type": "pause", "duration": 1}));
     }
 
     #[test]
     fn test_json_null_action_item_invalid_type() {
-        let json = r#"{"type":"invalid"}"#;
-        assert!(serde_json::from_str::<NullActionItem>(&json).is_err());
+        assert!(serde_json::from_value::<NullActionItem>(json!({"type": "invalid"})).is_err());
     }
 
     #[test]
     fn test_json_general_action_pause() {
-        let json = r#"{"type":"pause","duration":1}"#;
-        let data = GeneralAction::Pause(PauseAction { duration: Some(1) });
-
-        check_serialize_deserialize(&json, &data);
+        let pause = GeneralAction::Pause(PauseAction { duration: Some(1) });
+        assert_ser_de(&pause, json!({"type": "pause", "duration": 1}));
     }
 
     #[test]
     fn test_json_general_action_pause_with_duration_missing() {
-        let json = r#"{"type":"pause"}"#;
-        let data = GeneralAction::Pause(PauseAction { duration: None });
-
-        check_serialize_deserialize(&json, &data);
+        let pause = GeneralAction::Pause(PauseAction { duration: None });
+        assert_ser_de(&pause, json!({"type": "pause"}));
     }
 
     #[test]
     fn test_json_general_action_pause_with_duration_null() {
-        let json = r#"{"type":"pause","duration":null}"#;
-
-        assert!(serde_json::from_str::<GeneralAction>(&json).is_err());
+        let json = json!({"type": "pause", "duration": null});
+        assert!(serde_json::from_value::<GeneralAction>(json).is_err());
     }
 
     #[test]
     fn test_json_general_action_pause_with_duration_invalid_type() {
-        let json = r#"{"type":"pause","duration":"foo"}"#;
-
-        assert!(serde_json::from_str::<GeneralAction>(&json).is_err());
+        let json = json!({"type": "pause", "duration":" foo"});
+        assert!(serde_json::from_value::<GeneralAction>(json).is_err());
     }
 
     #[test]
     fn test_json_general_action_pause_with_duration_negative() {
-        let json = r#"{"type":"pause","duration":-30}"#;
-
-        assert!(serde_json::from_str::<GeneralAction>(&json).is_err());
+        let json = json!({"type": "pause", "duration": -30});
+        assert!(serde_json::from_value::<GeneralAction>(json).is_err());
     }
 
     #[test]
     fn test_json_key_action_item_general() {
-        let json = r#"{"type":"pause","duration":1}"#;
-        let data = KeyActionItem::General(GeneralAction::Pause(PauseAction { duration: Some(1) }));
-
-        check_serialize_deserialize(&json, &data);
+        let pause = KeyActionItem::General(GeneralAction::Pause(PauseAction { duration: Some(1) }));
+        assert_ser_de(&pause, json!({"type": "pause", "duration": 1}));
     }
 
     #[test]
     fn test_json_key_action_item_key() {
-        let json = r#"{"type":"keyDown","value":"f"}"#;
-        let data = KeyActionItem::Key(KeyAction::Down(KeyDownAction {
+        let key_down = KeyActionItem::Key(KeyAction::Down(KeyDownAction {
             value: String::from("f"),
         }));
-
-        check_serialize_deserialize(&json, &data);
+        assert_ser_de(&key_down, json!({"type": "keyDown", "value": "f"}));
     }
 
     #[test]
     fn test_json_key_action_item_invalid_type() {
-        let json = r#"{"type":"invalid"}"#;
-        assert!(serde_json::from_str::<KeyActionItem>(&json).is_err());
+        assert!(serde_json::from_value::<KeyActionItem>(json!({"type": "invalid"})).is_err());
     }
 
     #[test]
     fn test_json_key_action_missing_subtype() {
-        let json = r#"{"value":"f"}"#;
-
-        assert!(serde_json::from_str::<KeyAction>(&json).is_err());
+        assert!(serde_json::from_value::<KeyAction>(json!({"value": "f"})).is_err());
     }
 
     #[test]
     fn test_json_key_action_wrong_subtype() {
-        let json = r#"{"type":"pause","value":"f"}"#;
-
-        assert!(serde_json::from_str::<KeyAction>(&json).is_err());
+        let json = json!({"type": "pause", "value": "f"});
+        assert!(serde_json::from_value::<KeyAction>(json).is_err());
     }
 
     #[test]
     fn test_json_key_action_down() {
-        let json = r#"{"type":"keyDown","value":"f"}"#;
-        let data = KeyAction::Down(KeyDownAction {
-            value: "f".to_owned(),
+        let key_down = KeyAction::Down(KeyDownAction {
+            value: "f".to_string(),
         });
-
-        check_serialize_deserialize(&json, &data);
+        assert_ser_de(&key_down, json!({"type": "keyDown", "value": "f"}));
     }
 
     #[test]
     fn test_json_key_action_down_with_value_unicode() {
-        let json = r#"{"type":"keyDown","value":"à"}"#;
-        let data = KeyAction::Down(KeyDownAction {
-            value: "à".to_owned(),
+        let key_down = KeyAction::Down(KeyDownAction {
+            value: "à".to_string(),
         });
-
-        check_serialize_deserialize(&json, &data);
+        assert_ser_de(&key_down, json!({"type": "keyDown", "value": "à"}));
     }
 
     #[test]
     fn test_json_key_action_down_with_value_unicode_encoded() {
-        let json = r#"{"type":"keyDown","value":"\u00E0"}"#;
-        let data = KeyAction::Down(KeyDownAction {
-            value: "à".to_owned(),
+        let key_down = KeyAction::Down(KeyDownAction {
+            value: "à".to_string(),
         });
-
-        check_deserialize(&json, &data);
+        assert_de(&key_down, json!({"type": "keyDown", "value": "\u{00E0}"}));
     }
 
     #[test]
     fn test_json_key_action_down_with_value_missing() {
-        let json = r#"{"type":"keyDown"}"#;
-
-        assert!(serde_json::from_str::<KeyAction>(&json).is_err());
+        assert!(serde_json::from_value::<KeyAction>(json!({"type": "keyDown"})).is_err());
     }
 
     #[test]
     fn test_json_key_action_down_with_value_null() {
-        let json = r#"{"type":"keyDown","value":null}"#;
-
-        assert!(serde_json::from_str::<KeyAction>(&json).is_err());
+        let json = json!({"type": "keyDown", "value": null});
+        assert!(serde_json::from_value::<KeyAction>(json).is_err());
     }
 
     #[test]
     fn test_json_key_action_down_with_value_invalid_type() {
-        let json = r#"{"type":"keyDown,"value":["f","o","o"]}"#;
-
-        assert!(serde_json::from_str::<KeyAction>(&json).is_err());
+        let json = json!({"type": "keyDown", "value": ["f", "o", "o"]});
+        assert!(serde_json::from_value::<KeyAction>(json).is_err());
     }
 
     #[test]
     fn test_json_key_action_down_with_multiple_code_points() {
-        let json = r#"{"type":"keyDown","value":"fo"}"#;
-
-        assert!(serde_json::from_str::<KeyAction>(&json).is_err());
+        let json = json!({"type": "keyDown", "value": "fo"});
+        assert!(serde_json::from_value::<KeyAction>(json).is_err());
     }
 
     #[test]
     fn test_json_key_action_up() {
-        let json = r#"{"type":"keyUp","value":"f"}"#;
-        let data = KeyAction::Up(KeyUpAction {
-            value: "f".to_owned(),
+        let key_up = KeyAction::Up(KeyUpAction {
+            value: "f".to_string(),
         });
-
-        check_serialize_deserialize(&json, &data);
+        assert_ser_de(&key_up, json!({"type": "keyUp", "value": "f"}));
     }
 
     #[test]
     fn test_json_key_action_up_with_value_unicode() {
-        let json = r#"{"type":"keyUp","value":"à"}"#;
-        let data = KeyAction::Up(KeyUpAction {
-            value: "à".to_owned(),
+        let key_up = KeyAction::Up(KeyUpAction {
+            value: "à".to_string(),
         });
-
-        check_serialize_deserialize(&json, &data);
+        assert_ser_de(&key_up, json!({"type":"keyUp", "value": "à"}));
     }
 
     #[test]
     fn test_json_key_action_up_with_value_unicode_encoded() {
-        let json = r#"{"type":"keyUp","value":"\u00E0"}"#;
-        let data = KeyAction::Up(KeyUpAction {
-            value: "à".to_owned(),
+        let key_up = KeyAction::Up(KeyUpAction {
+            value: "à".to_string(),
         });
-
-        check_deserialize(&json, &data);
+        assert_de(&key_up, json!({"type": "keyUp", "value": "\u{00E0}"}));
     }
 
     #[test]
     fn test_json_key_action_up_with_value_missing() {
-        let json = r#"{"type":"keyUp"}"#;
-
-        assert!(serde_json::from_str::<KeyAction>(&json).is_err());
+        assert!(serde_json::from_value::<KeyAction>(json!({"type": "keyUp"})).is_err());
     }
 
     #[test]
     fn test_json_key_action_up_with_value_null() {
-        let json = r#"{"type":"keyUp,"value":null}"#;
-
-        assert!(serde_json::from_str::<KeyAction>(&json).is_err());
+        let json = json!({"type": "keyUp", "value": null});
+        assert!(serde_json::from_value::<KeyAction>(json).is_err());
     }
 
     #[test]
     fn test_json_key_action_up_with_value_invalid_type() {
-        let json = r#"{"type":"keyUp,"value":["f","o","o"]}"#;
-
-        assert!(serde_json::from_str::<KeyAction>(&json).is_err());
+        let json = json!({"type": "keyUp", "value": ["f","o","o"]});
+        assert!(serde_json::from_value::<KeyAction>(json).is_err());
     }
 
     #[test]
     fn test_json_key_action_up_with_multiple_code_points() {
-        let json = r#"{"type":"keyUp","value":"fo"}"#;
-
-        assert!(serde_json::from_str::<KeyAction>(&json).is_err());
+        let json = json!({"type": "keyUp", "value": "fo"});
+        assert!(serde_json::from_value::<KeyAction>(json).is_err());
     }
 
     #[test]
     fn test_json_pointer_action_item_general() {
-        let json = r#"{"type":"pause","duration":1}"#;
-        let data =
+        let pause =
             PointerActionItem::General(GeneralAction::Pause(PauseAction { duration: Some(1) }));
-
-        check_serialize_deserialize(&json, &data);
+        assert_ser_de(&pause, json!({"type": "pause", "duration": 1}));
     }
 
     #[test]
     fn test_json_pointer_action_item_pointer() {
-        let json = r#"{"type":"pointerCancel"}"#;
-        let data = PointerActionItem::Pointer(PointerAction::Cancel);
-
-        check_serialize_deserialize(&json, &data);
+        let cancel = PointerActionItem::Pointer(PointerAction::Cancel);
+        assert_ser_de(&cancel, json!({"type": "pointerCancel"}));
     }
 
     #[test]
     fn test_json_pointer_action_item_invalid() {
-        let json = r#"{"type":"invalid"}"#;
-
-        assert!(serde_json::from_str::<PointerActionItem>(&json).is_err());
+        assert!(serde_json::from_value::<PointerActionItem>(json!({"type": "invalid"})).is_err());
     }
 
     #[test]
     fn test_json_pointer_action_parameters_mouse() {
-        let json = r#"{"pointerType":"mouse"}"#;
-        let data = PointerActionParameters {
+        let mouse = PointerActionParameters {
             pointer_type: PointerType::Mouse,
         };
-
-        check_serialize_deserialize(&json, &data);
+        assert_ser_de(&mouse, json!({"pointerType": "mouse"}));
     }
 
     #[test]
     fn test_json_pointer_action_parameters_pen() {
-        let json = r#"{"pointerType":"pen"}"#;
-        let data = PointerActionParameters {
+        let pen = PointerActionParameters {
             pointer_type: PointerType::Pen,
         };
-
-        check_serialize_deserialize(&json, &data);
+        assert_ser_de(&pen, json!({"pointerType": "pen"}));
     }
 
     #[test]
     fn test_json_pointer_action_parameters_touch() {
-        let json = r#"{"pointerType":"touch"}"#;
-        let data = PointerActionParameters {
+        let touch = PointerActionParameters {
             pointer_type: PointerType::Touch,
         };
-
-        check_serialize_deserialize(&json, &data);
+        assert_ser_de(&touch, json!({"pointerType": "touch"}));
     }
 
     #[test]
     fn test_json_pointer_action_item_invalid_type() {
-        let json = r#"{"type":"pointerInvalid"}"#;
-        assert!(serde_json::from_str::<PointerActionItem>(&json).is_err());
-    }
-
-    #[test]
-    fn test_json_pointer_action_with_subtype_missing() {
-        let json = r#"{"button":1}"#;
-
-        assert!(serde_json::from_str::<PointerAction>(&json).is_err());
+        let json = json!({"type": "pointerInvalid"});
+        assert!(serde_json::from_value::<PointerActionItem>(json).is_err());
     }
 
     #[test]
-    fn test_json_pointer_action_with_subtype_invalid() {
-        let json = r#"{"type":"invalid"}"#;
-
-        assert!(serde_json::from_str::<PointerAction>(&json).is_err());
+    fn test_json_pointer_action_missing_subtype() {
+        assert!(serde_json::from_value::<PointerAction>(json!({"button": 1})).is_err());
     }
 
     #[test]
-    fn test_json_pointer_action_with_subtype_wrong() {
-        let json = r#"{"type":"pointerMove",button":1}"#;
-
-        assert!(serde_json::from_str::<PointerAction>(&json).is_err());
+    fn test_json_pointer_action_invalid_subtype() {
+        let json = json!({"type": "invalid", "button": 1});
+        assert!(serde_json::from_value::<PointerAction>(json).is_err());
     }
 
     #[test]
     fn test_json_pointer_action_cancel() {
-        let json = r#"{"type":"pointerCancel"}"#;
-        let data = PointerAction::Cancel;
-
-        check_serialize_deserialize(&json, &data);
+        assert_ser_de(&PointerAction::Cancel, json!({"type": "pointerCancel"}));
     }
 
     #[test]
     fn test_json_pointer_action_down() {
-        let json = r#"{"type":"pointerDown","button":1}"#;
-        let data = PointerAction::Down(PointerDownAction { button: 1 });
-
-        check_serialize_deserialize(&json, &data);
+        let pointer_down = PointerAction::Down(PointerDownAction { button: 1 });
+        assert_ser_de(&pointer_down, json!({"type": "pointerDown", "button": 1}));
     }
 
     #[test]
     fn test_json_pointer_action_down_with_button_missing() {
-        let json = r#"{"type":"pointerDown"}"#;
-
-        assert!(serde_json::from_str::<PointerAction>(&json).is_err());
+        let json = json!({"type": "pointerDown"});
+        assert!(serde_json::from_value::<PointerAction>(json).is_err());
     }
 
     #[test]
     fn test_json_pointer_action_down_with_button_null() {
-        let json = r#"{
-            "type":"pointerDown",
-            "button":null
-        }"#;
-
-        assert!(serde_json::from_str::<PointerAction>(&json).is_err());
+        let json = json!({
+            "type": "pointerDown",
+            "button": null,
+        });
+        assert!(serde_json::from_value::<PointerAction>(json).is_err());
     }
 
     #[test]
     fn test_json_pointer_action_down_with_button_invalid_type() {
-        let json = r#"{
-            "type":"pointerDown",
-            "button":"foo",
-        }"#;
-
-        assert!(serde_json::from_str::<PointerAction>(&json).is_err());
+        let json = json!({
+            "type": "pointerDown",
+            "button": "foo",
+        });
+        assert!(serde_json::from_value::<PointerAction>(json).is_err());
     }
 
     #[test]
     fn test_json_pointer_action_down_with_button_negative() {
-        let json = r#"{
-            "type":"pointerDown",
-            "button":-30
-        }"#;
-
-        assert!(serde_json::from_str::<PointerAction>(&json).is_err());
+        let json = json!({
+            "type": "pointerDown",
+            "button": -30,
+        });
+        assert!(serde_json::from_value::<PointerAction>(json).is_err());
     }
 
     #[test]
     fn test_json_pointer_action_move() {
-        let json = r#"{
-            "type":"pointerMove",
-            "duration":100,
-            "origin":"viewport",
-            "x":5,
-            "y":10
-        }"#;
-        let data = PointerAction::Move(PointerMoveAction {
+        let json = json!({
+            "type": "pointerMove",
+            "duration": 100,
+            "origin": "viewport",
+            "x": 5,
+            "y": 10,
+        });
+        let pointer_move = PointerAction::Move(PointerMoveAction {
             duration: Some(100),
             origin: PointerOrigin::Viewport,
             x: Some(5),
             y: Some(10),
         });
 
-        check_serialize_deserialize(&json, &data);
+        assert_ser_de(&pointer_move, json);
     }
 
     #[test]
     fn test_json_pointer_action_move_missing_subtype() {
-        let json = r#"{
-            "duration":100,
-            "origin":"viewport",
-            "x":5,
-            "y":10
-        }"#;
-
-        assert!(serde_json::from_str::<PointerAction>(&json).is_err());
+        let json = json!({
+            "duration": 100,
+            "origin": "viewport",
+            "x": 5,
+            "y": 10,
+        });
+        assert!(serde_json::from_value::<PointerAction>(json).is_err());
     }
 
     #[test]
     fn test_json_pointer_action_move_wrong_subtype() {
-        let json = r#"{
-            "type":"pointerUp",
-            "duration":100,
-            "origin":"viewport",
-            "x":5,
-            "y":10
-        }"#;
-
-        assert!(serde_json::from_str::<PointerAction>(&json).is_err());
+        let json = json!({
+            "type": "pointerUp",
+            "duration": 100,
+            "origin": "viewport",
+            "x": 5,
+            "y": 10,
+        });
+        assert!(serde_json::from_value::<PointerAction>(json).is_err());
     }
 
     #[test]
     fn test_json_pointer_action_move_with_duration_missing() {
-        let json = r#"{
-            "type":"pointerMove",
-            "origin":"viewport",
-            "x":5,
-            "y":10
-        }"#;
-        let data = PointerAction::Move(PointerMoveAction {
+        let json = json!({
+            "type": "pointerMove",
+            "origin": "viewport",
+            "x": 5,
+            "y": 10,
+        });
+        let pointer_move = PointerAction::Move(PointerMoveAction {
             duration: None,
             origin: PointerOrigin::Viewport,
             x: Some(5),
             y: Some(10),
         });
 
-        check_serialize_deserialize(&json, &data);
+        assert_ser_de(&pointer_move, json);
     }
 
     #[test]
     fn test_json_pointer_action_move_with_duration_null() {
-        let json = r#"{
-            "type":"pointerMove",
-            "duration":null,
-            "origin":"viewport",
-            "x":5,
-            "y":10
-        }"#;
-
-        assert!(serde_json::from_str::<PointerAction>(&json).is_err());
+        let json = json!({
+            "type": "pointerMove",
+            "duration": null,
+            "origin": "viewport",
+            "x": 5,
+            "y": 10,
+        });
+        assert!(serde_json::from_value::<PointerAction>(json).is_err());
     }
 
     #[test]
     fn test_json_pointer_action_move_with_duration_invalid_type() {
-        let json = r#"{
-            "type":"pointerMove",
-            "duration":"invalid",
-            "origin":"viewport",
-            "x":5,
-            "y":10
-        }"#;
-
-        assert!(serde_json::from_str::<PointerAction>(&json).is_err());
+        let json = json!({
+            "type": "pointerMove",
+            "duration": "invalid",
+            "origin": "viewport",
+            "x": 5,
+            "y": 10,
+        });
+        assert!(serde_json::from_value::<PointerAction>(json).is_err());
     }
 
     #[test]
     fn test_json_pointer_action_move_with_duration_negative() {
-        let json = r#"{
-            "type":"pointerMove",
-            "duration":-30,
-            "origin":"viewport",
-            "x":5,
-            "y":10
-        }"#;
-
-        assert!(serde_json::from_str::<PointerAction>(&json).is_err());
+        let json = json!({
+            "type": "pointerMove",
+            "duration": -30,
+            "origin": "viewport",
+            "x": 5,
+            "y": 10,
+        });
+        assert!(serde_json::from_value::<PointerAction>(json).is_err());
     }
 
     #[test]
     fn test_json_pointer_action_move_with_origin_missing() {
-        let json = r#"{
-            "type":"pointerMove",
-            "duration":100,
-            "x":5,
-            "y":10
-        }"#;
-        let data = PointerAction::Move(PointerMoveAction {
+        let json = json!({
+            "type": "pointerMove",
+            "duration": 100,
+            "x": 5,
+            "y": 10,
+        });
+        let pointer_move = PointerAction::Move(PointerMoveAction {
             duration: Some(100),
             origin: PointerOrigin::Viewport,
             x: Some(5),
             y: Some(10),
         });
 
-        check_deserialize(&json, &data);
+        assert_de(&pointer_move, json);
     }
 
     #[test]
     fn test_json_pointer_action_move_with_origin_webelement() {
-        let json = r#"{
-            "type":"pointerMove",
-            "duration":100,
-            "origin":{
-                "element-6066-11e4-a52e-4f735466cecf":"elem"
-            },
-            "x":5,
-            "y":10
-        }"#;
-        let data = PointerAction::Move(PointerMoveAction {
+        let json = json!({
+            "type": "pointerMove",
+            "duration": 100,
+            "origin": {ELEMENT_KEY: "elem"},
+            "x": 5,
+            "y": 10,
+        });
+        let pointer_move = PointerAction::Move(PointerMoveAction {
             duration: Some(100),
             origin: PointerOrigin::Element(WebElement("elem".into())),
             x: Some(5),
             y: Some(10),
         });
 
-        check_serialize_deserialize(&json, &data);
+        assert_ser_de(&pointer_move, json);
     }
 
     #[test]
     fn test_json_pointer_action_move_with_origin_webelement_and_legacy_element() {
-        let json = r#"{
-            "type":"pointerMove",
-            "duration":100,
-            "origin":{
-                "element-6066-11e4-a52e-4f735466cecf":"elem"
-            },
-            "x":5,
-            "y":10
-        }"#;
-        let data = PointerAction::Move(PointerMoveAction {
+        let json = json!({
+            "type": "pointerMove",
+            "duration": 100,
+            "origin": {ELEMENT_KEY: "elem"},
+            "x": 5,
+            "y": 10,
+        });
+        let pointer_move = PointerAction::Move(PointerMoveAction {
             duration: Some(100),
             origin: PointerOrigin::Element(WebElement("elem".into())),
             x: Some(5),
             y: Some(10),
         });
 
-        check_deserialize(&json, &data);
+        assert_de(&pointer_move, json);
     }
 
     #[test]
     fn test_json_pointer_action_move_with_origin_only_legacy_element() {
-        let json = r#"{
-            "type":"pointerMove",
-            "duration":100,
-            "origin":{
-                "element-6066-11e4-a52e-4f735466cecf":"elem"
-            },
-            "x":5,
-            "y":10
-        }"#;
-
-        assert!(serde_json::from_str::<PointerOrigin>(&json).is_err());
+        let json = json!({
+            "type": "pointerMove",
+            "duration": 100,
+            "origin": {ELEMENT_KEY: "elem"},
+            "x": 5,
+            "y": 10,
+        });
+        assert!(serde_json::from_value::<PointerOrigin>(json).is_err());
     }
 
     #[test]
     fn test_json_pointer_action_move_with_x_missing() {
-        let json = r#"{
-            "type":"pointerMove",
-            "duration":100,
-            "origin":"viewport",
-            "y":10
-        }"#;
-        let data = PointerAction::Move(PointerMoveAction {
+        let json = json!({
+            "type": "pointerMove",
+            "duration": 100,
+            "origin": "viewport",
+            "y": 10,
+        });
+        let pointer_move = PointerAction::Move(PointerMoveAction {
             duration: Some(100),
             origin: PointerOrigin::Viewport,
             x: None,
             y: Some(10),
         });
 
-        check_serialize_deserialize(&json, &data);
+        assert_ser_de(&pointer_move, json);
     }
 
     #[test]
     fn test_json_pointer_action_move_with_x_null() {
-        let json = r#"{
-            "type":"pointerMove",
-            "duration":100,
-            "origin":"viewport",
+        let json = json!({
+            "type": "pointerMove",
+            "duration": 100,
+            "origin": "viewport",
             "x": null,
-            "y":10
-        }"#;
-
-        assert!(serde_json::from_str::<PointerAction>(&json).is_err());
+            "y": 10,
+        });
+        assert!(serde_json::from_value::<PointerAction>(json).is_err());
     }
 
     #[test]
     fn test_json_pointer_action_move_with_x_invalid_type() {
-        let json = r#"{
-            "type":"pointerMove",
-            "duration":100,
-            "origin":"viewport",
+        let json = json!({
+            "type": "pointerMove",
+            "duration": 100,
+            "origin": "viewport",
             "x": "invalid",
-            "y":10
-        }"#;
-
-        assert!(serde_json::from_str::<PointerAction>(&json).is_err());
+            "y": 10,
+        });
+        assert!(serde_json::from_value::<PointerAction>(json).is_err());
     }
 
     #[test]
     fn test_json_pointer_action_move_with_y_missing() {
-        let json = r#"{
-            "type":"pointerMove",
-            "duration":100,
-            "origin":"viewport",
-            "x":5
-        }"#;
-        let data = PointerAction::Move(PointerMoveAction {
+        let json = json!({
+            "type": "pointerMove",
+            "duration": 100,
+            "origin": "viewport",
+            "x": 5,
+        });
+        let pointer_move = PointerAction::Move(PointerMoveAction {
             duration: Some(100),
             origin: PointerOrigin::Viewport,
             x: Some(5),
             y: None,
         });
 
-        check_serialize_deserialize(&json, &data);
+        assert_ser_de(&pointer_move, json);
     }
 
     #[test]
     fn test_json_pointer_action_move_with_y_null() {
-        let json = r#"{
-            "type":"pointerMove",
-            "duration":100,
-            "origin":"viewport",
-            "x":5,
-            "y":null
-        }"#;
-
-        assert!(serde_json::from_str::<PointerAction>(&json).is_err());
+        let json = json!({
+            "type": "pointerMove",
+            "duration": 100,
+            "origin": "viewport",
+            "x": 5,
+            "y": null,
+        });
+        assert!(serde_json::from_value::<PointerAction>(json).is_err());
     }
 
     #[test]
     fn test_json_pointer_action_move_with_y_invalid_type() {
-        let json = r#"{
-            "type":"pointerMove",
-            "duration":100,
-            "origin":"viewport",
-            "x":5,
-            "y":"invalid"
-        }"#;
-
-        assert!(serde_json::from_str::<PointerAction>(&json).is_err());
+        let json = json!({
+            "type": "pointerMove",
+            "duration": 100,
+            "origin": "viewport",
+            "x": 5,
+            "y": "invalid",
+        });
+        assert!(serde_json::from_value::<PointerAction>(json).is_err());
     }
 
     #[test]
     fn test_json_pointer_action_up() {
-        let json = r#"{
-            "type":"pointerUp",
-            "button":1
-        }"#;
-        let data = PointerAction::Up(PointerUpAction { button: 1 });
-
-        check_serialize_deserialize(&json, &data);
+        let pointer_up = PointerAction::Up(PointerUpAction { button: 1 });
+        assert_ser_de(&pointer_up, json!({"type": "pointerUp", "button": 1}));
     }
 
     #[test]
     fn test_json_pointer_action_up_with_button_missing() {
-        let json = r#"{
-            "type":"pointerUp"
-        }"#;
-
-        assert!(serde_json::from_str::<PointerAction>(&json).is_err());
+        assert!(serde_json::from_value::<PointerAction>(json!({"type": "pointerUp"})).is_err());
     }
 
     #[test]
     fn test_json_pointer_action_up_with_button_null() {
-        let json = r#"{
-            "type":"pointerUp",
-            "button":null
-        }"#;
-
-        assert!(serde_json::from_str::<PointerAction>(&json).is_err());
+        let json = json!({
+            "type": "pointerUp",
+            "button": null,
+        });
+        assert!(serde_json::from_value::<PointerAction>(json).is_err());
     }
 
     #[test]
     fn test_json_pointer_action_up_with_button_invalid_type() {
-        let json = r#"{
-            "type":"pointerUp",
-            "button":"foo",
-        }"#;
-
-        assert!(serde_json::from_str::<PointerAction>(&json).is_err());
+        let json = json!({
+            "type": "pointerUp",
+            "button": "foo",
+        });
+        assert!(serde_json::from_value::<PointerAction>(json).is_err());
     }
 
     #[test]
     fn test_json_pointer_action_up_with_button_negative() {
-        let json = r#"{
-            "type":"pointerUp",
-            "button":-30
-        }"#;
-
-        assert!(serde_json::from_str::<PointerAction>(&json).is_err());
+        let json = json!({
+            "type": "pointerUp",
+            "button": -30,
+        });
+        assert!(serde_json::from_value::<PointerAction>(json).is_err());
     }
 
     #[test]
     fn test_json_pointer_origin_pointer() {
-        let json = r#""pointer""#;
-        let data = PointerOrigin::Pointer;
-
-        check_serialize_deserialize(&json, &data);
+        assert_ser_de(&PointerOrigin::Pointer, json!("pointer"));
     }
 
     #[test]
     fn test_json_pointer_origin_viewport() {
-        let json = r#""viewport""#;
-        let data = PointerOrigin::Viewport;
-
-        check_serialize_deserialize(&json, &data);
+        assert_ser_de(&PointerOrigin::Viewport, json!("viewport"));
     }
 
     #[test]
     fn test_json_pointer_origin_web_element() {
-        let json = r#"{"element-6066-11e4-a52e-4f735466cecf":"elem"}"#;
-        let data = PointerOrigin::Element(WebElement("elem".into()));
-
-        check_serialize_deserialize(&json, &data);
+        let element = PointerOrigin::Element(WebElement("elem".into()));
+        assert_ser_de(&element, json!({ELEMENT_KEY: "elem"}));
     }
 
     #[test]
     fn test_json_pointer_origin_invalid_type() {
-        let data = r#""invalid""#;
-        assert!(serde_json::from_str::<PointerOrigin>(&data).is_err());
+        assert!(serde_json::from_value::<PointerOrigin>(json!("invalid")).is_err());
     }
 
     #[test]
     fn test_json_pointer_type_mouse() {
-        let json = r#""mouse""#;
-        let data = PointerType::Mouse;
-
-        check_serialize_deserialize(&json, &data);
+        assert_ser_de(&PointerType::Mouse, json!("mouse"));
     }
 
     #[test]
     fn test_json_pointer_type_pen() {
-        let json = r#""pen""#;
-        let data = PointerType::Pen;
-
-        check_serialize_deserialize(&json, &data);
+        assert_ser_de(&PointerType::Pen, json!("pen"));
     }
 
     #[test]
     fn test_json_pointer_type_touch() {
-        let json = r#""touch""#;
-        let data = PointerType::Touch;
-
-        check_serialize_deserialize(&json, &data);
+        assert_ser_de(&PointerType::Touch, json!("touch"));
     }
 
     #[test]
     fn test_json_pointer_type_invalid_type() {
-        let json = r#""invalid""#;
-        assert!(serde_json::from_str::<PointerType>(&json).is_err());
+        assert!(serde_json::from_value::<PointerType>(json!("invalid")).is_err());
     }
 }
--- a/testing/webdriver/src/capabilities.rs
+++ b/testing/webdriver/src/capabilities.rs
@@ -563,179 +563,171 @@ impl CapabilitiesMatching for LegacyNewS
         browser_capabilities.init(&capabilities);
         Ok(Some(capabilities))
     }
 }
 
 #[cfg(test)]
 mod tests {
     use super::*;
-    use crate::test::check_deserialize;
-    use serde_json::{self, Value};
-
-    fn validate_proxy(value: &str) -> WebDriverResult<()> {
-        let data = serde_json::from_str::<Value>(value).unwrap();
-        SpecNewSessionParameters::validate_proxy(&data)
-    }
+    use crate::test::assert_de;
+    use serde_json::{self, json};
 
     #[test]
     fn test_json_spec_new_session_parameters_alwaysMatch_only() {
-        let json = r#"{
-            "alwaysMatch":{}
-        }"#;
-        let data = SpecNewSessionParameters {
+        let caps = SpecNewSessionParameters {
             alwaysMatch: Capabilities::new(),
             firstMatch: vec![Capabilities::new()],
         };
-
-        check_deserialize(&json, &data);
+        assert_de(&caps, json!({"alwaysMatch": {}}));
     }
 
     #[test]
     fn test_json_spec_new_session_parameters_firstMatch_only() {
-        let json = r#"{
-            "firstMatch":[{}]
-        }"#;
-        let data = SpecNewSessionParameters {
+        let caps = SpecNewSessionParameters {
             alwaysMatch: Capabilities::new(),
             firstMatch: vec![Capabilities::new()],
         };
-
-        check_deserialize(&json, &data);
+        assert_de(&caps, json!({"firstMatch": [{}]}));
     }
 
     #[test]
     fn test_json_spec_new_session_parameters_alwaysMatch_null() {
-        let json = r#"{
-            "alwaysMatch":null,
-            "firstMatch":[{}]
-        }"#;
-
-        assert!(serde_json::from_str::<SpecNewSessionParameters>(&json).is_err());
+        let json = json!({
+            "alwaysMatch": null,
+            "firstMatch": [{}],
+        });
+        assert!(serde_json::from_value::<SpecNewSessionParameters>(json).is_err());
     }
 
     #[test]
     fn test_json_spec_new_session_parameters_firstMatch_null() {
-        let json = r#"{
-            "alwaysMatch":{},
-            "firstMatch":null
-        }"#;
-
-        assert!(serde_json::from_str::<SpecNewSessionParameters>(&json).is_err());
+        let json = json!({
+            "alwaysMatch": {},
+            "firstMatch": null,
+        });
+        assert!(serde_json::from_value::<SpecNewSessionParameters>(json).is_err());
     }
 
     #[test]
     fn test_json_spec_new_session_parameters_both_empty() {
-        let json = r#"{
-            "alwaysMatch":{},
-            "firstMatch":[{}]
-        }"#;
-        let data = SpecNewSessionParameters {
+        let json = json!({
+            "alwaysMatch": {},
+            "firstMatch": [{}],
+        });
+        let caps = SpecNewSessionParameters {
             alwaysMatch: Capabilities::new(),
             firstMatch: vec![Capabilities::new()],
         };
 
-        check_deserialize(&json, &data);
+        assert_de(&caps, json);
     }
 
     #[test]
     fn test_json_spec_new_session_parameters_both_with_capability() {
-        let json = r#"{
-            "alwaysMatch":{"foo":"bar"},
-            "firstMatch":[{"foo2":"bar2"}]
-        }"#;
-        let mut data = SpecNewSessionParameters {
+        let json = json!({
+            "alwaysMatch": {"foo": "bar"},
+            "firstMatch": [{"foo2": "bar2"}],
+        });
+        let mut caps = SpecNewSessionParameters {
             alwaysMatch: Capabilities::new(),
             firstMatch: vec![Capabilities::new()],
         };
-        data.alwaysMatch.insert("foo".into(), "bar".into());
-        data.firstMatch[0].insert("foo2".into(), "bar2".into());
+        caps.alwaysMatch.insert("foo".into(), "bar".into());
+        caps.firstMatch[0].insert("foo2".into(), "bar2".into());
 
-        check_deserialize(&json, &data);
+        assert_de(&caps, json);
     }
 
     #[test]
     fn test_json_spec_legacy_new_session_parameters_desired_only() {
-        let json = r#"{"desiredCapabilities":{}}"#;
-        let data = LegacyNewSessionParameters {
+        let caps = LegacyNewSessionParameters {
             desired: Capabilities::new(),
             required: Capabilities::new(),
         };
-
-        check_deserialize(&json, &data);
+        assert_de(&caps, json!({"desiredCapabilities": {}}));
     }
 
     #[test]
     fn test_json_spec_legacy_new_session_parameters_required_only() {
-        let json = r#"{"requiredCapabilities":{}}"#;
-        let data = LegacyNewSessionParameters {
+        let caps = LegacyNewSessionParameters {
             desired: Capabilities::new(),
             required: Capabilities::new(),
         };
-
-        check_deserialize(&json, &data);
+        assert_de(&caps, json!({"requiredCapabilities": {}}));
     }
 
     #[test]
     fn test_json_spec_legacy_new_session_parameters_desired_null() {
-        let json = r#"{"desiredCapabilities":null,"requiredCapabilities":{}}"#;
-
-        assert!(serde_json::from_str::<LegacyNewSessionParameters>(&json).is_err());
+        let json = json!({
+            "desiredCapabilities": null,
+            "requiredCapabilities": {},
+        });
+        assert!(serde_json::from_value::<LegacyNewSessionParameters>(json).is_err());
     }
 
     #[test]
     fn test_json_spec_legacy_new_session_parameters_required_null() {
-        let json = r#"{"desiredCapabilities":{}, "requiredCapabilities":null}"#;
-
-        assert!(serde_json::from_str::<LegacyNewSessionParameters>(&json).is_err());
+        let json = json!({
+            "desiredCapabilities": {},
+            "requiredCapabilities": null,
+        });
+        assert!(serde_json::from_value::<LegacyNewSessionParameters>(json).is_err());
     }
 
     #[test]
     fn test_json_spec_legacy_new_session_parameters_both_empty() {
-        let json = r#"{"desiredCapabilities":{},"requiredCapabilities":{}}"#;
-        let data = LegacyNewSessionParameters {
+        let json = json!({
+            "desiredCapabilities": {},
+            "requiredCapabilities": {},
+        });
+        let caps = LegacyNewSessionParameters {
             desired: Capabilities::new(),
             required: Capabilities::new(),
         };
 
-        check_deserialize(&json, &data);
+        assert_de(&caps, json);
     }
 
     #[test]
     fn test_json_spec_legacy_new_session_parameters_both_with_capabilities() {
-        let json = r#"{
-            "desiredCapabilities":{"foo":"bar"},
-            "requiredCapabilities":{"foo2":"bar2"}
-        }"#;
-        let mut data = LegacyNewSessionParameters {
+        let json = json!({
+            "desiredCapabilities": {"foo": "bar"},
+            "requiredCapabilities": {"foo2": "bar2"},
+        });
+        let mut caps = LegacyNewSessionParameters {
             desired: Capabilities::new(),
             required: Capabilities::new(),
         };
-        data.desired.insert("foo".into(), "bar".into());
-        data.required.insert("foo2".into(), "bar2".into());
+        caps.desired.insert("foo".into(), "bar".into());
+        caps.required.insert("foo2".into(), "bar2".into());
 
-        check_deserialize(&json, &data);
+        assert_de(&caps, json);
     }
 
     #[test]
     fn test_validate_proxy() {
+        fn validate_proxy(v: Value) -> WebDriverResult<()> {
+            SpecNewSessionParameters::validate_proxy(&v)
+        }
+
         // proxy hosts
-        validate_proxy("{\"httpProxy\": \"127.0.0.1\"}").unwrap();
-        validate_proxy("{\"httpProxy\": \"127.0.0.1:\"}").unwrap();
-        validate_proxy("{\"httpProxy\": \"127.0.0.1:3128\"}").unwrap();
-        validate_proxy("{\"httpProxy\": \"localhost\"}").unwrap();
-        validate_proxy("{\"httpProxy\": \"localhost:3128\"}").unwrap();
-        validate_proxy("{\"httpProxy\": \"[2001:db8::1]\"}").unwrap();
-        validate_proxy("{\"httpProxy\": \"[2001:db8::1]:3128\"}").unwrap();
-        validate_proxy("{\"httpProxy\": \"example.org\"}").unwrap();
-        validate_proxy("{\"httpProxy\": \"example.org:3128\"}").unwrap();
+        validate_proxy(json!({"httpProxy":  "127.0.0.1"})).unwrap();
+        validate_proxy(json!({"httpProxy": "127.0.0.1:"})).unwrap();
+        validate_proxy(json!({"httpProxy": "127.0.0.1:3128"})).unwrap();
+        validate_proxy(json!({"httpProxy": "localhost"})).unwrap();
+        validate_proxy(json!({"httpProxy": "localhost:3128"})).unwrap();
+        validate_proxy(json!({"httpProxy": "[2001:db8::1]"})).unwrap();
+        validate_proxy(json!({"httpProxy": "[2001:db8::1]:3128"})).unwrap();
+        validate_proxy(json!({"httpProxy": "example.org"})).unwrap();
+        validate_proxy(json!({"httpProxy": "example.org:3128"})).unwrap();
 
-        assert!(validate_proxy("{\"httpProxy\": \"http://example.org\"}").is_err());
-        assert!(validate_proxy("{\"httpProxy\": \"example.org:-1\"}").is_err());
-        assert!(validate_proxy("{\"httpProxy\": \"2001:db8::1\"}").is_err());
+        assert!(validate_proxy(json!({"httpProxy": "http://example.org"})).is_err());
+        assert!(validate_proxy(json!({"httpProxy": "example.org:-1"})).is_err());
+        assert!(validate_proxy(json!({"httpProxy": "2001:db8::1"})).is_err());
 
         // no proxy for manual proxy type
-        validate_proxy("{\"noProxy\": [\"foo\"]}").unwrap();
+        validate_proxy(json!({"noProxy": ["foo"]})).unwrap();
 
-        assert!(validate_proxy("{\"noProxy\": \"foo\"}").is_err());
-        assert!(validate_proxy("{\"noProxy\": [42]}").is_err());
+        assert!(validate_proxy(json!({"noProxy": "foo"})).is_err());
+        assert!(validate_proxy(json!({"noProxy": [42]})).is_err());
     }
 }
--- a/testing/webdriver/src/command.rs
+++ b/testing/webdriver/src/command.rs
@@ -657,727 +657,721 @@ where
 
     Ok(value)
 }
 
 #[cfg(test)]
 mod tests {
     use super::*;
     use crate::capabilities::SpecNewSessionParameters;
-    use crate::test::check_deserialize;
-    use serde_json;
+    use crate::common::ELEMENT_KEY;
+    use crate::test::assert_de;
+    use serde_json::{self, json};
 
     #[test]
     fn test_json_actions_parameters_missing_actions_field() {
-        let json = r#"{}"#;
-        assert!(serde_json::from_str::<ActionsParameters>(&json).is_err());
+        assert!(serde_json::from_value::<ActionsParameters>(json!({})).is_err());
     }
 
     #[test]
     fn test_json_actions_parameters_invalid() {
-        let json = r#"{"actions":null}"#;
-        assert!(serde_json::from_str::<ActionsParameters>(&json).is_err());
+        assert!(serde_json::from_value::<ActionsParameters>(json!({ "actions": null })).is_err());
     }
 
     #[test]
     fn test_json_action_parameters_empty_list() {
-        let json = r#"{"actions":[]}"#;
-        let data = ActionsParameters { actions: vec![] };
-
-        check_deserialize(&json, &data);
+        assert_de(
+            &ActionsParameters { actions: vec![] },
+            json!({"actions": []}),
+        );
     }
 
     #[test]
     fn test_json_action_parameters_with_unknown_field() {
-        let json = r#"{"actions":[],"foo":"bar"}"#;
-        let data = ActionsParameters { actions: vec![] };
-
-        check_deserialize(&json, &data);
+        assert_de(
+            &ActionsParameters { actions: vec![] },
+            json!({"actions": [], "foo": "bar"}),
+        );
     }
 
     #[test]
     fn test_json_add_cookie_parameters_with_values() {
-        let json = r#"{"cookie":{
-            "name":"foo",
-            "value":"bar",
-            "path":"/",
-            "domain":"foo.bar",
-            "expiry":123,
-            "secure":true,
-            "httpOnly":false
-        }}"#;
-        let data = AddCookieParameters {
+        let json = json!({"cookie": {
+            "name": "foo",
+            "value": "bar",
+            "path": "/",
+            "domain": "foo.bar",
+            "expiry": 123,
+            "secure": true,
+            "httpOnly": false,
+        }});
+        let cookie = AddCookieParameters {
             name: "foo".into(),
             value: "bar".into(),
             path: Some("/".into()),
             domain: Some("foo.bar".into()),
             expiry: Some(Date(123)),
             secure: true,
             httpOnly: false,
         };
 
-        check_deserialize(&json, &data);
+        assert_de(&cookie, json);
     }
 
     #[test]
     fn test_json_add_cookie_parameters_with_optional_null_fields() {
-        let json = r#"{"cookie":{
-            "name":"foo",
-            "value":"bar",
-            "path":null,
-            "domain":null,
-            "expiry":null,
-            "secure":true,
-            "httpOnly":false
-        }}"#;
-        let data = AddCookieParameters {
+        let json = json!({"cookie": {
+            "name": "foo",
+            "value": "bar",
+            "path": null,
+            "domain": null,
+            "expiry": null,
+            "secure": true,
+            "httpOnly": false,
+        }});
+        let cookie = AddCookieParameters {
             name: "foo".into(),
             value: "bar".into(),
             path: None,
             domain: None,
             expiry: None,
             secure: true,
             httpOnly: false,
         };
 
-        check_deserialize(&json, &data);
+        assert_de(&cookie, json);
     }
 
     #[test]
     fn test_json_add_cookie_parameters_without_optional_fields() {
-        let json = r#"{"cookie":{
-            "name":"foo",
-            "value":"bar",
-            "secure":true,
-            "httpOnly":false
-        }}"#;
-        let data = AddCookieParameters {
+        let json = json!({"cookie": {
+            "name": "foo",
+            "value": "bar",
+            "secure": true,
+            "httpOnly": false,
+        }});
+        let cookie = AddCookieParameters {
             name: "foo".into(),
             value: "bar".into(),
             path: None,
             domain: None,
             expiry: None,
             secure: true,
             httpOnly: false,
         };
 
-        check_deserialize(&json, &data);
+        assert_de(&cookie, json);
     }
 
     #[test]
     fn test_json_add_cookie_parameters_with_invalid_cookie_field() {
-        let json = r#"{"name":"foo"}"#;
-
-        assert!(serde_json::from_str::<AddCookieParameters>(&json).is_err());
+        assert!(serde_json::from_value::<AddCookieParameters>(json!({"name": "foo"})).is_err());
     }
 
     #[test]
     fn test_json_add_cookie_parameters_with_unknown_field() {
-        let json = r#"{"cookie":{
-            "name":"foo",
-            "value":"bar",
-            "secure":true,
-            "httpOnly":false,
-            "foo":"bar"
-        },"foo":"bar"}"#;
-        let data = AddCookieParameters {
+        let json = json!({"cookie": {
+            "name": "foo",
+            "value": "bar",
+            "secure": true,
+            "httpOnly": false,
+            "foo": "bar",
+        }, "baz": "bah"});
+        let cookie = AddCookieParameters {
             name: "foo".into(),
             value: "bar".into(),
             path: None,
             domain: None,
             expiry: None,
             secure: true,
             httpOnly: false,
         };
 
-        check_deserialize(&json, &data);
+        assert_de(&cookie, json);
     }
 
     #[test]
     fn test_json_get_parameters_with_url() {
-        let json = r#"{"url":"foo.bar"}"#;
-        let data = GetParameters {
-            url: "foo.bar".into(),
-        };
-
-        check_deserialize(&json, &data);
+        assert_de(
+            &GetParameters {
+                url: "foo.bar".into(),
+            },
+            json!({"url": "foo.bar"}),
+        );
     }
 
     #[test]
     fn test_json_get_parameters_with_invalid_url_value() {
-        let json = r#"{"url":3}"#;
-
-        assert!(serde_json::from_str::<GetParameters>(&json).is_err());
+        assert!(serde_json::from_value::<GetParameters>(json!({"url": 3})).is_err());
     }
 
     #[test]
     fn test_json_get_parameters_with_invalid_url_field() {
-        let json = r#"{"foo":"bar"}"#;
-
-        assert!(serde_json::from_str::<GetParameters>(&json).is_err());
+        assert!(serde_json::from_value::<GetParameters>(json!({"foo": "bar"})).is_err());
     }
 
     #[test]
     fn test_json_get_parameters_with_unknown_field() {
-        let json = r#"{"url":"foo.bar","foo":"bar"}"#;
-        let data = GetParameters {
-            url: "foo.bar".into(),
-        };
-
-        check_deserialize(&json, &data);
+        assert_de(
+            &GetParameters {
+                url: "foo.bar".into(),
+            },
+            json!({"url": "foo.bar", "foo": "bar"}),
+        );
     }
 
     #[test]
     fn test_json_get_named_cookie_parameters_with_value() {
-        let json = r#"{"name":"foo"}"#;
-        let data = GetNamedCookieParameters {
-            name: Some("foo".into()),
-        };
-
-        check_deserialize(&json, &data);
+        assert_de(
+            &GetNamedCookieParameters {
+                name: Some("foo".into()),
+            },
+            json!({"name": "foo"}),
+        );
     }
 
     #[test]
     fn test_json_get_named_cookie_parameters_with_optional_null_field() {
-        let json = r#"{"name":null}"#;
-        let data = GetNamedCookieParameters { name: None };
-
-        check_deserialize(&json, &data);
+        assert_de(
+            &GetNamedCookieParameters { name: None },
+            json!({ "name": null }),
+        );
     }
 
     #[test]
     fn test_json_get_named_cookie_parameters_without_optional_null_field() {
-        let json = r#"{}"#;
-        let data = GetNamedCookieParameters { name: None };
-
-        check_deserialize(&json, &data);
+        assert_de(&GetNamedCookieParameters { name: None }, json!({}));
     }
 
     #[test]
     fn test_json_get_named_cookie_parameters_with_invalid_name_field() {
-        let json = r#"{"name":3"#;
-
-        assert!(serde_json::from_str::<GetNamedCookieParameters>(&json).is_err());
+        assert!(serde_json::from_value::<GetNamedCookieParameters>(json!({"name": 3})).is_err());
     }
 
     #[test]
     fn test_json_get_named_cookie_parameters_with_unknown_field() {
-        let json = r#"{"name":"foo","foo":"bar"}"#;
-        let data = GetNamedCookieParameters {
-            name: Some("foo".into()),
-        };
-
-        check_deserialize(&json, &data);
+        assert_de(
+            &GetNamedCookieParameters {
+                name: Some("foo".into()),
+            },
+            json!({"name": "foo", "foo": "bar"}),
+        );
     }
 
     #[test]
     fn test_json_javascript_command_parameters_with_values() {
-        let json = r#"{"script":"foo","args":["1",2]}"#;
-        let data = JavascriptCommandParameters {
+        let json = json!({
+            "script": "foo",
+            "args": ["1", 2],
+        });
+        let execute_script = JavascriptCommandParameters {
             script: "foo".into(),
             args: Some(vec!["1".into(), 2.into()]),
         };
 
-        check_deserialize(&json, &data);
+        assert_de(&execute_script, json);
     }
 
     #[test]
     fn test_json_javascript_command_parameters_with_optional_null_field() {
-        let json = r#"{"script":"foo","args":null}"#;
-        let data = JavascriptCommandParameters {
+        let json = json!({
+            "script": "foo",
+            "args": null,
+        });
+        let execute_script = JavascriptCommandParameters {
             script: "foo".into(),
             args: None,
         };
 
-        check_deserialize(&json, &data);
+        assert_de(&execute_script, json);
     }
 
     #[test]
     fn test_json_javascript_command_parameters_without_optional_null_field() {
-        let json = r#"{"script":"foo"}"#;
-        let data = JavascriptCommandParameters {
+        let execute_script = JavascriptCommandParameters {
             script: "foo".into(),
             args: None,
         };
-
-        check_deserialize(&json, &data);
+        assert_de(&execute_script, json!({"script": "foo"}));
     }
 
     #[test]
     fn test_json_javascript_command_parameters_invalid_script_field() {
-        let json = r#"{"script":null}"#;
-
-        assert!(serde_json::from_str::<JavascriptCommandParameters>(&json).is_err());
+        let json = json!({ "script": null });
+        assert!(serde_json::from_value::<JavascriptCommandParameters>(json).is_err());
     }
 
     #[test]
     fn test_json_javascript_command_parameters_invalid_args_field() {
-        let json = r#"{"script":null,"args":"1"}"#;
-
-        assert!(serde_json::from_str::<JavascriptCommandParameters>(&json).is_err());
+        let json = json!({
+            "script": null,
+            "args": "1",
+        });
+        assert!(serde_json::from_value::<JavascriptCommandParameters>(json).is_err());
     }
 
     #[test]
     fn test_json_javascript_command_parameters_missing_script_field() {
-        let json = r#"{"args":null}"#;
-
-        assert!(serde_json::from_str::<JavascriptCommandParameters>(&json).is_err());
+        let json = json!({ "args": null });
+        assert!(serde_json::from_value::<JavascriptCommandParameters>(json).is_err());
     }
 
     #[test]
     fn test_json_javascript_command_parameters_with_unknown_field() {
-        let json = r#"{"script":"foo","foo":"bar"}"#;
-        let data = JavascriptCommandParameters {
+        let json = json!({
+            "script": "foo",
+            "foo": "bar",
+        });
+        let execute_script = JavascriptCommandParameters {
             script: "foo".into(),
             args: None,
         };
 
-        check_deserialize(&json, &data);
+        assert_de(&execute_script, json);
     }
 
     #[test]
     fn test_json_locator_parameters_with_values() {
-        let json = r#"{"using":"xpath","value":"bar"}"#;
-        let data = LocatorParameters {
+        let json = json!({
+            "using": "xpath",
+            "value": "bar",
+        });
+        let locator = LocatorParameters {
             using: LocatorStrategy::XPath,
             value: "bar".into(),
         };
 
-        check_deserialize(&json, &data);
+        assert_de(&locator, json);
     }
 
     #[test]
     fn test_json_locator_parameters_invalid_using_field() {
-        let json = r#"{"using":"foo","value":"bar"}"#;
-
-        assert!(serde_json::from_str::<LocatorParameters>(&json).is_err());
+        let json = json!({
+            "using": "foo",
+            "value": "bar",
+        });
+        assert!(serde_json::from_value::<LocatorParameters>(json).is_err());
     }
 
     #[test]
     fn test_json_locator_parameters_invalid_value_field() {
-        let json = r#"{"using":"xpath","value":3}"#;
-
-        assert!(serde_json::from_str::<LocatorParameters>(&json).is_err());
+        let json = json!({
+            "using": "xpath",
+            "value": 3,
+        });
+        assert!(serde_json::from_value::<LocatorParameters>(json).is_err());
     }
 
     #[test]
     fn test_json_locator_parameters_missing_using_field() {
-        let json = r#"{"value":"bar"}"#;
-
-        assert!(serde_json::from_str::<LocatorParameters>(&json).is_err());
+        assert!(serde_json::from_value::<LocatorParameters>(json!({"value": "bar"})).is_err());
     }
 
     #[test]
     fn test_json_locator_parameters_missing_value_field() {
-        let json = r#"{"using":"xpath"}"#;
-
-        assert!(serde_json::from_str::<LocatorParameters>(&json).is_err());
+        assert!(serde_json::from_value::<LocatorParameters>(json!({"using": "xpath"})).is_err());
     }
 
     #[test]
     fn test_json_locator_parameters_with_unknown_field() {
-        let json = r#"{"using":"xpath","value":"bar","foo":"bar"}"#;
-        let data = LocatorParameters {
+        let json = json!({
+            "using": "xpath",
+            "value": "bar",
+            "foo": "bar",
+        });
+        let locator = LocatorParameters {
             using: LocatorStrategy::XPath,
             value: "bar".into(),
         };
 
-        check_deserialize(&json, &data);
+        assert_de(&locator, json);
     }
 
     #[test]
     fn test_json_new_session_parameters_spec() {
-        let json = r#"{"capabilities":{"alwaysMatch":{},"firstMatch":[{}]}}"#;
-        let data = NewSessionParameters::Spec(SpecNewSessionParameters {
+        let json = json!({"capabilities": {
+            "alwaysMatch": {},
+            "firstMatch": [{}],
+        }});
+        let caps = NewSessionParameters::Spec(SpecNewSessionParameters {
             alwaysMatch: Capabilities::new(),
             firstMatch: vec![Capabilities::new()],
         });
 
-        check_deserialize(&json, &data);
+        assert_de(&caps, json);
     }
 
     #[test]
     fn test_json_new_session_parameters_capabilities_null() {
-        let json = r#"{"capabilities":null}"#;
-
-        assert!(serde_json::from_str::<NewSessionParameters>(&json).is_err());
+        let json = json!({ "capabilities": null });
+        assert!(serde_json::from_value::<NewSessionParameters>(json).is_err());
     }
 
     #[test]
     fn test_json_new_session_parameters_legacy() {
-        let json = r#"{"desired":{},"required":{}}"#;
-        let data = NewSessionParameters::Legacy(LegacyNewSessionParameters {
+        let json = json!({
+            "desiredCapabilities": {},
+            "requiredCapabilities": {},
+        });
+        let caps = NewSessionParameters::Legacy(LegacyNewSessionParameters {
             desired: Capabilities::new(),
             required: Capabilities::new(),
         });
 
-        check_deserialize(&json, &data);
+        assert_de(&caps, json);
     }
 
     #[test]
     fn test_json_new_session_parameters_spec_and_legacy() {
-        let json = r#"{
-            "capabilities":{
-                "alwaysMatch":{},
-                "firstMatch":[{}]
+        let json = json!({
+            "capabilities": {
+                "alwaysMatch": {},
+                "firstMatch": [{}],
             },
-            "desired":{},
-            "required":{}
-        }"#;
-        let data = NewSessionParameters::Spec(SpecNewSessionParameters {
+            "desiredCapabilities": {},
+            "requiredCapabilities": {},
+        });
+        let caps = NewSessionParameters::Spec(SpecNewSessionParameters {
             alwaysMatch: Capabilities::new(),
             firstMatch: vec![Capabilities::new()],
         });
 
-        check_deserialize(&json, &data);
+        assert_de(&caps, json);
     }
 
     #[test]
     fn test_json_new_session_parameters_with_unknown_field() {
-        let json = r#"{
-            "capabilities":{
-                "alwaysMatch":{},
-                "firstMatch":[{}]
+        let json = json!({
+            "capabilities": {
+                "alwaysMatch": {},
+                "firstMatch": [{}]
             },
-            "foo":"bar"}"#;
-        let data = NewSessionParameters::Spec(SpecNewSessionParameters {
+            "foo": "bar",
+        });
+        let caps = NewSessionParameters::Spec(SpecNewSessionParameters {
             alwaysMatch: Capabilities::new(),
             firstMatch: vec![Capabilities::new()],
         });
 
-        check_deserialize(&json, &data);
+        assert_de(&caps, json);
     }
 
     #[test]
     fn test_json_new_window_parameters_without_type() {
-        let json = r#"{}"#;
-        let data = NewWindowParameters { type_hint: None };
-
-        check_deserialize(&json, &data);
+        assert_de(&NewWindowParameters { type_hint: None }, json!({}));
     }
 
     #[test]
     fn test_json_new_window_parameters_with_optional_null_type() {
-        let json = r#"{"type":null}"#;
-        let data = NewWindowParameters { type_hint: None };
-
-        check_deserialize(&json, &data);
+        assert_de(
+            &NewWindowParameters { type_hint: None },
+            json!({ "type": null }),
+        );
     }
 
     #[test]
     fn test_json_new_window_parameters_with_supported_type() {
-        let json = r#"{"type":"tab"}"#;
-        let data = NewWindowParameters {
-            type_hint: Some("tab".into()),
-        };
-
-        check_deserialize(&json, &data);
+        assert_de(
+            &NewWindowParameters {
+                type_hint: Some("tab".into()),
+            },
+            json!({"type": "tab"}),
+        );
     }
 
     #[test]
     fn test_json_new_window_parameters_with_unknown_type() {
-        let json = r#"{"type":"foo"}"#;
-        let data = NewWindowParameters {
-            type_hint: Some("foo".into()),
-        };
-
-        check_deserialize(&json, &data);
+        assert_de(
+            &NewWindowParameters {
+                type_hint: Some("foo".into()),
+            },
+            json!({"type": "foo"}),
+        );
     }
 
     #[test]
     fn test_json_new_window_parameters_with_invalid_type() {
-        let json = r#"{"type":3}"#;
-
-        assert!(serde_json::from_str::<NewWindowParameters>(&json).is_err());
+        assert!(serde_json::from_value::<NewWindowParameters>(json!({"type": 3})).is_err());
     }
 
     #[test]
     fn test_json_new_window_parameters_with_unknown_field() {
-        let json = r#"{"type":"tab","foo":"bar"}"#;
-        let data = NewWindowParameters {
+        let json = json!({
+            "type": "tab",
+            "foo": "bar",
+        });
+        let new_window = NewWindowParameters {
             type_hint: Some("tab".into()),
         };
 
-        check_deserialize(&json, &data);
+        assert_de(&new_window, json);
     }
 
     #[test]
     fn test_json_send_keys_parameters_with_value() {
-        let json = r#"{"text":"foo"}"#;
-        let data = SendKeysParameters { text: "foo".into() };
-
-        check_deserialize(&json, &data);
+        assert_de(
+            &SendKeysParameters { text: "foo".into() },
+            json!({"text": "foo"}),
+        );
     }
 
     #[test]
     fn test_json_send_keys_parameters_invalid_text_field() {
-        let json = r#"{"text":3}"#;
-
-        assert!(serde_json::from_str::<SendKeysParameters>(&json).is_err());
+        assert!(serde_json::from_value::<SendKeysParameters>(json!({"text": 3})).is_err());
     }
 
     #[test]
     fn test_json_send_keys_parameters_missing_text_field() {
-        let json = r#"{}"#;
-
-        assert!(serde_json::from_str::<SendKeysParameters>(&json).is_err());
+        assert!(serde_json::from_value::<SendKeysParameters>(json!({})).is_err());
     }
 
     #[test]
     fn test_json_send_keys_parameters_with_unknown_field() {
-        let json = r#"{"text":"foo","foo":"bar"}"#;
-        let data = SendKeysParameters { text: "foo".into() };
+        let json = json!({
+            "text": "foo",
+            "foo": "bar",
+        });
+        let send_keys = SendKeysParameters { text: "foo".into() };
 
-        check_deserialize(&json, &data);
+        assert_de(&send_keys, json);
     }
 
     #[test]
     fn test_json_switch_to_frame_parameters_with_value() {
-        let json = r#"{"id":3}"#;
-        let data = SwitchToFrameParameters {
-            id: Some(FrameId::Short(3)),
-        };
-
-        check_deserialize(&json, &data);
+        assert_de(
+            &SwitchToFrameParameters {
+                id: Some(FrameId::Short(3)),
+            },
+            json!({"id": 3}),
+        );
     }
 
     #[test]
     fn test_json_switch_to_frame_parameters_with_optional_null_field() {
-        let json = r#"{"id":null}"#;
-        let data = SwitchToFrameParameters { id: None };
-
-        check_deserialize(&json, &data);
+        assert_de(&SwitchToFrameParameters { id: None }, json!({ "id": null }));
     }
 
     #[test]
     fn test_json_switch_to_frame_parameters_without_optional_null_field() {
-        let json = r#"{}"#;
-        let data = SwitchToFrameParameters { id: None };
-
-        check_deserialize(&json, &data);
+        assert_de(&SwitchToFrameParameters { id: None }, json!({}));
     }
 
     #[test]
     fn test_json_switch_to_frame_parameters_with_invalid_id_field() {
-        let json = r#"{"id":"3"}"#;
-
-        assert!(serde_json::from_str::<SwitchToFrameParameters>(&json).is_err());
+        assert!(serde_json::from_value::<SwitchToFrameParameters>(json!({"id": "3"})).is_err());
     }
 
     #[test]
     fn test_json_switch_to_frame_parameters_with_unknown_field() {
-        let json = r#"{"id":3,"foo":"bar"}"#;
-        let data = SwitchToFrameParameters {
+        let json = json!({
+            "id":3,
+            "foo": "bar",
+        });
+        let switch_to_frame = SwitchToFrameParameters {
             id: Some(FrameId::Short(3)),
         };
 
-        check_deserialize(&json, &data);
+        assert_de(&switch_to_frame, json);
     }
 
     #[test]
     fn test_json_switch_to_window_parameters_with_value() {
-        let json = r#"{"handle":"foo"}"#;
-        let data = SwitchToWindowParameters {
-            handle: "foo".into(),
-        };
-
-        check_deserialize(&json, &data);
+        assert_de(
+            &SwitchToWindowParameters {
+                handle: "foo".into(),
+            },
+            json!({"handle": "foo"}),
+        );
     }
 
     #[test]
     fn test_json_switch_to_window_parameters_invalid_handle_field() {
-        let json = r#"{"handle":3}"#;
-
-        assert!(serde_json::from_str::<SwitchToWindowParameters>(&json).is_err());
+        assert!(serde_json::from_value::<SwitchToWindowParameters>(json!({"handle": 3})).is_err());
     }
 
     #[test]
     fn test_json_switch_to_window_parameters_missing_handle_field() {
-        let json = r#"{}"#;
-
-        assert!(serde_json::from_str::<SwitchToWindowParameters>(&json).is_err());
+        assert!(serde_json::from_value::<SwitchToWindowParameters>(json!({})).is_err());
     }
 
     #[test]
     fn test_json_switch_to_window_parameters_with_unknown_field() {
-        let json = r#"{"handle":"foo","foo":"bar"}"#;
-        let data = SwitchToWindowParameters {
+        let json = json!({
+            "handle": "foo",
+            "foo": "bar",
+        });
+        let switch_to_window = SwitchToWindowParameters {
             handle: "foo".into(),
         };
 
-        check_deserialize(&json, &data);
+        assert_de(&switch_to_window, json);
     }
 
     #[test]
     fn test_json_take_screenshot_parameters_with_element() {
-        let json = r#"{"element":{"element-6066-11e4-a52e-4f735466cecf":"elem"}}"#;
-        let data = TakeScreenshotParameters {
-            element: Some(WebElement("elem".into())),
-        };
-
-        check_deserialize(&json, &data);
+        assert_de(
+            &TakeScreenshotParameters {
+                element: Some(WebElement("elem".into())),
+            },
+            json!({"element": {ELEMENT_KEY: "elem"}}),
+        );
     }
 
     #[test]
     fn test_json_take_screenshot_parameters_with_optional_null_field() {
-        let json = r#"{"element":null}"#;
-        let data = TakeScreenshotParameters { element: None };
-
-        check_deserialize(&json, &data);
+        assert_de(
+            &TakeScreenshotParameters { element: None },
+            json!({ "element": null }),
+        );
     }
 
     #[test]
     fn test_json_take_screenshot_parameters_without_optional_null_field() {
-        let json = r#"{}"#;
-        let data = TakeScreenshotParameters { element: None };
-
-        check_deserialize(&json, &data);
+        assert_de(&TakeScreenshotParameters { element: None }, json!({}));
     }
 
     #[test]
     fn test_json_take_screenshot_parameters_with_invalid_element_field() {
-        let json = r#"{"element":"foo"}"#;
-        assert!(serde_json::from_str::<TakeScreenshotParameters>(&json).is_err());
+        assert!(
+            serde_json::from_value::<TakeScreenshotParameters>(json!({"element": "foo"})).is_err()
+        );
     }
 
     #[test]
     fn test_json_take_screenshot_parameters_with_unknown_field() {
-        let json = r#"{"element":{"element-6066-11e4-a52e-4f735466cecf":"elem"},"foo":"bar"}"#;
-        let data = TakeScreenshotParameters {
+        let json = json!({
+            "element": {ELEMENT_KEY: "elem"},
+            "foo": "bar",
+        });
+        let take_screenshot = TakeScreenshotParameters {
             element: Some(WebElement("elem".into())),
         };
 
-        check_deserialize(&json, &data);
-    }
-
-    #[test]
-    fn test_json_timeout_parameters_with_values() {
-        let json = r#"{"implicit":0,"pageLoad":2.0,"script":9007199254740991}"#;
-        let data = TimeoutsParameters {
-            implicit: Some(0u64),
-            page_load: Some(2u64),
-            script: Some(Some(9_007_199_254_740_991u64)),
-        };
-
-        check_deserialize(&json, &data);
-    }
-
-    #[test]
-    fn test_json_timeout_parameters_with_invalid_values() {
-        let json = r#"{"implicit":-1,"pageLoad":2.5,"script":9007199254740992}"#;
-        assert!(serde_json::from_str::<TimeoutsParameters>(&json).is_err());
+        assert_de(&take_screenshot, json);
     }
 
     #[test]
     fn test_json_timeout_parameters_with_only_null_script_timeout() {
-        let json = r#"{"script":null}"#;
-        let data = TimeoutsParameters {
+        let timeouts = TimeoutsParameters {
             implicit: None,
             page_load: None,
             script: Some(None),
         };
-
-        check_deserialize(&json, &data);
+        assert_de(&timeouts, json!({ "script": null }));
     }
 
     #[test]
     fn test_json_timeout_parameters_with_only_null_implicit_timeout() {
-        let json = r#"{"implicit":null}"#;
-
-        assert!(serde_json::from_str::<TimeoutsParameters>(&json).is_err());
+        assert!(serde_json::from_value::<TimeoutsParameters>(json!({ "implicit": null })).is_err());
     }
 
     #[test]
     fn test_json_timeout_parameters_with_only_null_pageload_timeout() {
-        let json = r#"{"pageLoad":null}"#;
-
-        assert!(serde_json::from_str::<TimeoutsParameters>(&json).is_err());
+        assert!(serde_json::from_value::<TimeoutsParameters>(json!({ "pageLoad": null })).is_err());
     }
 
     #[test]
     fn test_json_timeout_parameters_without_optional_null_field() {
-        let json = r#"{}"#;
-        let data = TimeoutsParameters {
+        let timeouts = TimeoutsParameters {
             implicit: None,
             page_load: None,
             script: None,
         };
-
-        check_deserialize(&json, &data);
+        assert_de(&timeouts, json!({}));
     }
 
     #[test]
     fn test_json_timeout_parameters_with_unknown_field() {
-        let json = r#"{"script":60000,"foo":"bar"}"#;
-        let data = TimeoutsParameters {
+        let json = json!({
+            "script": 60000,
+            "foo": "bar",
+        });
+        let timeouts = TimeoutsParameters {
             implicit: None,
             page_load: None,
             script: Some(Some(60000)),
         };
 
-        check_deserialize(&json, &data);
+        assert_de(&timeouts, json);
     }
 
     #[test]
     fn test_json_window_rect_parameters_with_values() {
-        let json = r#"{"x":0,"y":1,"width":2,"height":3}"#;
-        let data = WindowRectParameters {
+        let json = json!({
+            "x": 0,
+            "y": 1,
+            "width": 2,
+            "height": 3,
+        });
+        let rect = WindowRectParameters {
             x: Some(0i32),
             y: Some(1i32),
             width: Some(2i32),
             height: Some(3i32),
         };
 
-        check_deserialize(&json, &data);
+        assert_de(&rect, json);
     }
 
     #[test]
     fn test_json_window_rect_parameters_with_optional_null_fields() {
-        let json = r#"{"x":null,"y": null,"width":null,"height":null}"#;
-        let data = WindowRectParameters {
-            x: None,
-            y: None,
-            width: None,
-            height: None,
-        };
-
-        check_deserialize(&json, &data);
-    }
-
-    #[test]
-    fn test_json_window_rect_parameters_without_optional_fields() {
-        let json = r#"{}"#;
-        let data = WindowRectParameters {
+        let json = json!({
+            "x": null,
+            "y": null,
+            "width": null,
+            "height": null,
+        });
+        let rect = WindowRectParameters {
             x: None,
             y: None,
             width: None,
             height: None,
         };
 
-        check_deserialize(&json, &data);
+        assert_de(&rect, json);
+    }
+
+    #[test]
+    fn test_json_window_rect_parameters_without_optional_fields() {
+        let rect = WindowRectParameters {
+            x: None,
+            y: None,
+            width: None,
+            height: None,
+        };
+        assert_de(&rect, json!({}));
     }
 
     #[test]
     fn test_json_window_rect_parameters_invalid_values_float() {
-        let json = r#"{"x":1.1,"y":2.2,"width":3.3,"height":4.4}"#;
-        let data = WindowRectParameters {
+        let json = json!({
+            "x": 1.1,
+            "y": 2.2,
+            "width": 3.3,
+            "height": 4.4,
+        });
+        let rect = WindowRectParameters {
             x: Some(1),
             y: Some(2),
             width: Some(3),
             height: Some(4),
         };
 
-        check_deserialize(&json, &data);
+        assert_de(&rect, json);
     }
 
     #[test]
     fn test_json_window_rect_parameters_with_unknown_field() {
-        let json = r#"{"x":1.1,"y":2.2,"foo":"bar"}"#;
-        let data = WindowRectParameters {
+        let json = json!({
+            "x": 1.1,
+            "y": 2.2,
+            "foo": "bar",
+        });
+        let rect = WindowRectParameters {
             x: Some(1),
             y: Some(2),
             width: None,
             height: None,
         };
 
-        check_deserialize(&json, &data);
+        assert_de(&rect, json);
     }
 }
--- a/testing/webdriver/src/common.rs
+++ b/testing/webdriver/src/common.rs
@@ -148,135 +148,102 @@ impl<'de> Deserialize<'de> for WebWindow
     {
         Deserialize::deserialize(deserializer).map(|WebWindowObject { id }| WebWindow(id))
     }
 }
 
 #[cfg(test)]
 mod tests {
     use super::*;
-    use crate::test::{check_serialize, check_serialize_deserialize};
-    use serde_json;
+    use crate::test::{assert_ser, assert_ser_de};
+    use serde_json::{self, json};
 
     #[test]
     fn test_json_date() {
-        let json = r#"1234"#;
-        let data = Date(1234);
-
-        check_serialize_deserialize(&json, &data);
+        assert_ser_de(&Date(1234), json!(1234));
     }
 
     #[test]
     fn test_json_date_invalid() {
-        let json = r#""2018-01-01""#;
-        assert!(serde_json::from_str::<Date>(&json).is_err());
+        assert!(serde_json::from_value::<Date>(json!("2018-01-01")).is_err());
     }
 
     #[test]
     fn test_json_frame_id_short() {
-        let json = r#"1234"#;
-        let data = FrameId::Short(1234);
-
-        check_serialize_deserialize(&json, &data);
+        assert_ser_de(&FrameId::Short(1234), json!(1234));
     }
 
     #[test]
     fn test_json_frame_id_webelement() {
-        let json = r#"{"element-6066-11e4-a52e-4f735466cecf":"elem"}"#;
-        let data = FrameId::Element(WebElement("elem".into()));
-
-        check_serialize(&json, &data);
+        assert_ser(
+            &FrameId::Element(WebElement("elem".into())),
+            json!({ELEMENT_KEY: "elem"}),
+        );
     }
 
     #[test]
     fn test_json_frame_id_invalid() {
-        let json = r#"true"#;
-        assert!(serde_json::from_str::<FrameId>(&json).is_err());
+        assert!(serde_json::from_value::<FrameId>(json!(true)).is_err());
     }
 
     #[test]
     fn test_json_locator_strategy_css_selector() {
-        let json = r#""css selector""#;
-        let data = LocatorStrategy::CSSSelector;
-
-        check_serialize_deserialize(&json, &data);
+        assert_ser_de(&LocatorStrategy::CSSSelector, json!("css selector"));
     }
 
     #[test]
     fn test_json_locator_strategy_link_text() {
-        let json = r#""link text""#;
-        let data = LocatorStrategy::LinkText;
-
-        check_serialize_deserialize(&json, &data);
+        assert_ser_de(&LocatorStrategy::LinkText, json!("link text"));
     }
 
     #[test]
     fn test_json_locator_strategy_partial_link_text() {
-        let json = r#""partial link text""#;
-        let data = LocatorStrategy::PartialLinkText;
-
-        check_serialize_deserialize(&json, &data);
+        assert_ser_de(
+            &LocatorStrategy::PartialLinkText,
+            json!("partial link text"),
+        );
     }
 
     #[test]
     fn test_json_locator_strategy_tag_name() {
-        let json = r#""tag name""#;
-        let data = LocatorStrategy::TagName;
-
-        check_serialize_deserialize(&json, &data);
+        assert_ser_de(&LocatorStrategy::TagName, json!("tag name"));
     }
 
     #[test]
     fn test_json_locator_strategy_xpath() {
-        let json = r#""xpath""#;
-        let data = LocatorStrategy::XPath;
-
-        check_serialize_deserialize(&json, &data);
+        assert_ser_de(&LocatorStrategy::XPath, json!("xpath"));
     }
 
     #[test]
     fn test_json_locator_strategy_invalid() {
-        let json = r#""foo""#;
-        assert!(serde_json::from_str::<LocatorStrategy>(&json).is_err());
+        assert!(serde_json::from_value::<LocatorStrategy>(json!("foo")).is_err());
     }
 
     #[test]
     fn test_json_webelement() {
-        let json = r#"{"element-6066-11e4-a52e-4f735466cecf":"elem"}"#;
-        let data = WebElement("elem".into());
-
-        check_serialize_deserialize(&json, &data);
+        assert_ser_de(&WebElement("elem".into()), json!({ELEMENT_KEY: "elem"}));
     }
 
     #[test]
     fn test_json_webelement_invalid() {
-        let data = r#"{"elem-6066-11e4-a52e-4f735466cecf":"elem"}"#;
-        assert!(serde_json::from_str::<WebElement>(&data).is_err());
+        assert!(serde_json::from_value::<WebElement>(json!({"invalid": "elem"})).is_err());
     }
 
     #[test]
     fn test_json_webframe() {
-        let json = r#"{"frame-075b-4da1-b6ba-e579c2d3230a":"frm"}"#;
-        let data = WebFrame("frm".into());
-
-        check_serialize_deserialize(&json, &data);
+        assert_ser_de(&WebFrame("frame".into()), json!({FRAME_KEY: "frame"}));
     }
 
     #[test]
     fn test_json_webframe_invalid() {
-        let data = r#"{"frm-075b-4da1-b6ba-e579c2d3230a":"frm"}"#;
-        assert!(serde_json::from_str::<WebFrame>(&data).is_err());
+        assert!(serde_json::from_value::<WebFrame>(json!({"invalid": "frame"})).is_err());
     }
 
     #[test]
     fn test_json_webwindow() {
-        let json = r#"{"window-fcc6-11e5-b4f8-330a88ab9d7f":"window"}"#;
-        let data = WebWindow("window".into());
-
-        check_serialize_deserialize(&json, &data);
+        assert_ser_de(&WebWindow("window".into()), json!({WINDOW_KEY: "window"}));
     }
 
     #[test]
     fn test_json_webwindow_invalid() {
-        let data = r#"{""wind-fcc6-11e5-b4f8-330a88ab9d7f":"window"}"#;
-        assert!(serde_json::from_str::<WebWindow>(&data).is_err());
+        assert!(serde_json::from_value::<WebWindow>(json!({"invalid": "window"})).is_err());
     }
 }
--- a/testing/webdriver/src/error.rs
+++ b/testing/webdriver/src/error.rs
@@ -368,36 +368,35 @@ impl From<DecodeError> for WebDriverErro
 impl From<Box<dyn Error>> for WebDriverError {
     fn from(err: Box<dyn Error>) -> WebDriverError {
         WebDriverError::new(ErrorStatus::UnknownError, err.description().to_string())
     }
 }
 
 #[cfg(test)]
 mod tests {
+    use serde_json::json;
+
     use super::*;
-    use crate::test::check_serialize;
+    use crate::test::assert_ser;
 
     #[test]
     fn test_json_webdriver_error() {
-        let json = r#"{"value":{
-            "error":"unknown error",
-            "message":"foo bar",
-            "stacktrace":"foo\nbar"
-        }}"#;
-        let data = WebDriverError {
+        let json = json!({"value": {
+            "error": "unknown error",
+            "message": "foo bar",
+            "stacktrace": "foo\nbar",
+        }});
+        let error = WebDriverError {
             error: ErrorStatus::UnknownError,
             message: "foo bar".into(),
             stack: "foo\nbar".into(),
             delete_session: true,
         };
 
-        check_serialize(&json, &data);
+        assert_ser(&error, json);
     }
 
     #[test]
     fn test_json_error_status() {
-        let json = format!(r#""unknown error""#);
-        let data = ErrorStatus::UnknownError;
-
-        check_serialize(&json, &data);
+        assert_ser(&ErrorStatus::UnknownError, json!("unknown error"));
     }
 }
--- a/testing/webdriver/src/lib.rs
+++ b/testing/webdriver/src/lib.rs
@@ -1,17 +1,16 @@
 #![allow(non_snake_case)]
 #![forbid(unsafe_code)]
 
 extern crate base64;
 extern crate cookie;
 #[macro_use]
 extern crate log;
 extern crate http;
-extern crate regex;
 extern crate serde;
 #[macro_use]
 extern crate serde_derive;
 extern crate serde_json;
 extern crate time;
 extern crate tokio;
 extern crate unicode_segmentation;
 extern crate url;
@@ -24,14 +23,11 @@ pub mod capabilities;
 pub mod command;
 pub mod common;
 pub mod error;
 pub mod httpapi;
 pub mod response;
 pub mod server;
 
 #[cfg(test)]
-#[macro_use]
-extern crate lazy_static;
-#[cfg(test)]
 pub mod test;
 
 pub use common::Parameters;
--- a/testing/webdriver/src/response.rs
+++ b/testing/webdriver/src/response.rs
@@ -131,185 +131,188 @@ pub struct WindowRectResponse {
     /// Height of the top-level browsing context’s outer dimensions, including
     /// any browser chrome and externally drawn window decorations in CSS
     /// reference pixels.
     pub height: i32,
 }
 
 #[cfg(test)]
 mod tests {
+    use serde_json::{json, Map};
+
     use super::*;
     use crate::common::Date;
-    use crate::test::check_serialize;
-    use serde_json;
+    use crate::test::assert_ser;
 
     #[test]
     fn test_json_new_window_response() {
-        let json = r#"{"value":{"handle":"42","type":"window"}}"#;
-        let data = WebDriverResponse::NewWindow(NewWindowResponse {
+        let json = json!({"value": {"handle": "42", "type": "window"}});
+        let response = WebDriverResponse::NewWindow(NewWindowResponse {
             handle: "42".into(),
             typ: "window".into(),
         });
 
-        check_serialize(&json, &data);
+        assert_ser(&response, json);
     }
 
     #[test]
     fn test_json_close_window_response() {
-        let json = r#"{"value":["1234"]}"#;
-        let data = WebDriverResponse::CloseWindow(CloseWindowResponse(vec!["1234".into()]));
-
-        check_serialize(&json, &data);
+        assert_ser(
+            &WebDriverResponse::CloseWindow(CloseWindowResponse(vec!["1234".into()])),
+            json!({"value": ["1234"]}),
+        );
     }
 
     #[test]
     fn test_json_cookie_response_with_optional() {
-        let json = r#"{"value":{
-            "name":"foo",
-            "value":"bar",
-            "path":"/",
-            "domain":"foo.bar",
-            "secure":true,
-            "httpOnly":false,
-            "expiry":123
-        }}"#;
-        let data = WebDriverResponse::Cookie(CookieResponse(Cookie {
+        let json = json!({"value": {
+            "name": "foo",
+            "value": "bar",
+            "path": "/",
+            "domain": "foo.bar",
+            "secure": true,
+            "httpOnly": false,
+            "expiry": 123,
+        }});
+        let response = WebDriverResponse::Cookie(CookieResponse(Cookie {
             name: "foo".into(),
             value: "bar".into(),
             path: Some("/".into()),
             domain: Some("foo.bar".into()),
             expiry: Some(Date(123)),
             secure: true,
             http_only: false,
         }));
 
-        check_serialize(&json, &data);
+        assert_ser(&response, json);
     }
 
     #[test]
     fn test_json_cookie_response_without_optional() {
-        let json = r#"{"value":{
-            "name":"foo",
-            "value":"bar",
-            "path":"/",
-            "domain":null,
-            "secure":true,
-            "httpOnly":false
-        }}"#;
-        let data = WebDriverResponse::Cookie(CookieResponse(Cookie {
+        let json = json!({"value": {
+            "name": "foo",
+            "value": "bar",
+            "path": "/",
+            "domain": null,
+            "secure": true,
+            "httpOnly": false,
+        }});
+        let response = WebDriverResponse::Cookie(CookieResponse(Cookie {
             name: "foo".into(),
             value: "bar".into(),
             path: Some("/".into()),
             domain: None,
             expiry: None,
             secure: true,
             http_only: false,
         }));
 
-        check_serialize(&json, &data);
+        assert_ser(&response, json);
     }
 
     #[test]
     fn test_json_cookies_response() {
-        let json = r#"{"value":[{
-            "name":"name",
-            "value":"value",
-            "path":"/",
-            "domain":null,
-            "secure":true,
-            "httpOnly":false
-        }]}"#;
-        let data = WebDriverResponse::Cookies(CookiesResponse(vec![Cookie {
+        let json = json!({"value": [{
+            "name": "name",
+            "value": "value",
+            "path": "/",
+            "domain": null,
+            "secure": true,
+            "httpOnly": false,
+        }]});
+        let response = WebDriverResponse::Cookies(CookiesResponse(vec![Cookie {
             name: "name".into(),
             value: "value".into(),
             path: Some("/".into()),
             domain: None,
             expiry: None,
             secure: true,
             http_only: false,
         }]));
 
-        check_serialize(&json, &data);
+        assert_ser(&response, json);
     }
 
     #[test]
     fn test_json_delete_session_response() {
-        let json = r#"{"value":null}"#;
-        let data = WebDriverResponse::DeleteSession;
-
-        check_serialize(&json, &data);
+        assert_ser(&WebDriverResponse::DeleteSession, json!({ "value": null }));
     }
 
     #[test]
     fn test_json_element_rect_response() {
-        let json = r#"{"value":{"x":0.0,"y":1.0,"width":2.0,"height":3.0}}"#;
-        let data = WebDriverResponse::ElementRect(ElementRectResponse {
+        let json = json!({"value": {
+            "x": 0.0,
+            "y": 1.0,
+            "width": 2.0,
+            "height": 3.0,
+        }});
+        let response = WebDriverResponse::ElementRect(ElementRectResponse {
             x: 0f64,
             y: 1f64,
             width: 2f64,
             height: 3f64,
         });
 
-        check_serialize(&json, &data);
+        assert_ser(&response, json);
     }
 
     #[test]
     fn test_json_generic_value_response() {
-        let json = r#"{"value":{"example":["test"]}}"#;
-        let mut value = serde_json::Map::new();
-        value.insert(
-            "example".into(),
-            Value::Array(vec![Value::String("test".into())]),
-        );
-
-        let data = WebDriverResponse::Generic(ValueResponse(Value::Object(value)));
-
-        check_serialize(&json, &data);
+        let response = {
+            let mut value = Map::new();
+            value.insert(
+                "example".into(),
+                Value::Array(vec![Value::String("test".into())]),
+            );
+            WebDriverResponse::Generic(ValueResponse(Value::Object(value)))
+        };
+        assert_ser(&response, json!({"value": {"example": ["test"]}}));
     }
 
     #[test]
     fn test_json_new_session_response() {
-        let json = r#"{"value":{"sessionId":"id","capabilities":{}}}"#;
-        let data = WebDriverResponse::NewSession(NewSessionResponse::new(
-            "id".into(),
-            Value::Object(serde_json::Map::new()),
-        ));
-
-        check_serialize(&json, &data);
+        let response =
+            WebDriverResponse::NewSession(NewSessionResponse::new("id".into(), json!({})));
+        assert_ser(
+            &response,
+            json!({"value": {"sessionId": "id", "capabilities": {}}}),
+        );
     }
 
     #[test]
     fn test_json_timeouts_response() {
-        let json = r#"{"value":{"script":1,"pageLoad":2,"implicit":3}}"#;
-        let data = WebDriverResponse::Timeouts(TimeoutsResponse::new(Some(1), 2, 3));
-
-        check_serialize(&json, &data);
+        assert_ser(
+            &WebDriverResponse::Timeouts(TimeoutsResponse::new(Some(1), 2, 3)),
+            json!({"value": {"script": 1, "pageLoad": 2, "implicit": 3}}),
+        );
     }
 
     #[test]
     fn test_json_timeouts_response_with_null_script_timeout() {
-        let json = r#"{"value":{"script":null,"pageLoad":2,"implicit":3}}"#;
-        let data = WebDriverResponse::Timeouts(TimeoutsResponse::new(None, 2, 3));
-
-        check_serialize(&json, &data);
+        assert_ser(
+            &WebDriverResponse::Timeouts(TimeoutsResponse::new(None, 2, 3)),
+            json!({"value": {"script": null, "pageLoad": 2, "implicit": 3}}),
+        );
     }
 
     #[test]
     fn test_json_void_response() {
-        let json = r#"{"value":null}"#;
-        let data = WebDriverResponse::Void;
-
-        check_serialize(&json, &data);
+        assert_ser(&WebDriverResponse::Void, json!({ "value": null }));
     }
 
     #[test]
     fn test_json_window_rect_response() {
-        let json = r#"{"value":{"x":0,"y":1,"width":2,"height":3}}"#;
-        let data = WebDriverResponse::WindowRect(WindowRectResponse {
+        let json = json!({"value": {
+            "x": 0,
+            "y": 1,
+            "width": 2,
+            "height": 3,
+        }});
+        let response = WebDriverResponse::WindowRect(WindowRectResponse {
             x: 0i32,
             y: 1i32,
             width: 2i32,
             height: 3i32,
         });
 
-        check_serialize(&json, &data);
+        assert_ser(&response, json);
     }
 }
--- a/testing/webdriver/src/test.rs
+++ b/testing/webdriver/src/test.rs
@@ -1,43 +1,28 @@
-use regex::Regex;
-use serde;
-use serde_json;
-use std;
-
-lazy_static! {
-    static ref MIN_REGEX: Regex = Regex::new(r"[\n\t]|\s{4}").unwrap();
-}
-
-pub fn check_serialize_deserialize<T>(json: &str, data: &T)
+pub fn assert_ser_de<T>(data: &T, json: serde_json::Value)
 where
     T: std::fmt::Debug,
     T: std::cmp::PartialEq,
     T: serde::de::DeserializeOwned,
     T: serde::Serialize,
 {
-    let min_json = MIN_REGEX.replace_all(json, "");
-
-    assert_eq!(*data, serde_json::from_str::<T>(&min_json).unwrap());
-    assert_eq!(min_json, serde_json::to_string(data).unwrap());
+    assert_eq!(serde_json::to_value(data).unwrap(), json);
+    assert_eq!(data, &serde_json::from_value::<T>(json).unwrap());
 }
 
-pub fn check_deserialize<T>(json: &str, data: &T)
+pub fn assert_ser<T>(data: &T, json: serde_json::Value)
+where
+    T: std::fmt::Debug,
+    T: std::cmp::PartialEq,
+    T: serde::Serialize,
+{
+    assert_eq!(serde_json::to_value(data).unwrap(), json);
+}
+
+pub fn assert_de<T>(data: &T, json: serde_json::Value)
 where
     T: std::fmt::Debug,
     T: std::cmp::PartialEq,
     T: serde::de::DeserializeOwned,
 {
-    let min_json = MIN_REGEX.replace_all(json, "");
-
-    assert_eq!(serde_json::from_str::<T>(&min_json).unwrap(), *data);
+    assert_eq!(data, &serde_json::from_value::<T>(json).unwrap());
 }
-
-pub fn check_serialize<T>(json: &str, data: &T)
-where
-    T: std::fmt::Debug,
-    T: std::cmp::PartialEq,
-    T: serde::Serialize,
-{
-    let min_json = MIN_REGEX.replace_all(json, "");
-
-    assert_eq!(min_json, serde_json::to_string(data).unwrap());
-}