From aa963db8545e1c1b79fd8a4a82065e122670ec03 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Sun, 28 Oct 2018 12:43:32 -0700 Subject: [PATCH] Fix WebDriver compat with Safari They've made a few breaking changes in the most recent version, so let's support that plus the old protocol for now! Closes #983 --- .../src/bin/wasm-bindgen-test-runner/headless.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/crates/cli/src/bin/wasm-bindgen-test-runner/headless.rs b/crates/cli/src/bin/wasm-bindgen-test-runner/headless.rs index 4648e71748c..8b8e87c6a37 100644 --- a/crates/cli/src/bin/wasm-bindgen-test-runner/headless.rs +++ b/crates/cli/src/bin/wasm-bindgen-test-runner/headless.rs @@ -284,15 +284,27 @@ impl Client { Driver::Safari(_) => { #[derive(Deserialize)] struct Response { + // returned by `--legacy` + #[serde(rename = "sessionId")] + session_id: Option, + // returned by the now-default `--w3c` mode + value: Option, + } + #[derive(Deserialize)] + struct Value { #[serde(rename = "sessionId")] session_id: String, } let request = json!({ + // this is needed for the now `--legacy` mode "desiredCapabilities": { + }, + // this is needed for the now `--w3c` (default) mode + "capabilities": { } }); let x: Response = self.post("/session", &request)?; - Ok(x.session_id) + Ok(x.session_id.or(x.value.map(|v| v.session_id)).unwrap()) } Driver::Chrome(_) => { #[derive(Deserialize)]