Use new endpoints for chromedriver

master
Myriad-Dreamin 2 years ago
parent 7d6501d3cd
commit fc220e8afb
  1. 38
      src/test/webdriver/chromedriver.rs

@ -5,6 +5,7 @@ use crate::target;
use anyhow::{bail, Context, Result};
use binary_install::Cache;
use chrono::DateTime;
use std::collections::HashMap;
use std::path::PathBuf;
// Keep it up to date with each `wasm-pack` release.
@ -116,19 +117,44 @@ fn should_load_chromedriver_version_from_stamp(json: &serde_json::Value) -> bool
}
}
/// Channel information from the chromedriver version endpoint.
#[derive(Deserialize)]
struct ChannelInfo {
version: String,
}
/// The response from the chromedriver version endpoint.
#[derive(Deserialize)]
struct GoodLatestVersions {
channels: HashMap<String, ChannelInfo>,
}
/// Retrieve the latest version of chromedriver from the json endpoints.
/// See: <https://github.com/GoogleChromeLabs/chrome-for-testing#json-api-endpoints>
fn fetch_chromedriver_version() -> Result<String> {
let version = ureq::get("https://chromedriver.storage.googleapis.com/LATEST_RELEASE")
.call()
.context("fetching of chromedriver's LATEST_RELEASE failed")?
.into_string()
.context("converting chromedriver version response to string failed")?;
let info: GoodLatestVersions = ureq::get(
"https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions.json",
)
.call()
.context("fetching of chromedriver's LATEST_RELEASE failed")?
.into_json()
.context("converting chromedriver version response to GoodLatestVersions failed")?;
let version = info
.channels
.get("Stable")
.ok_or_else(|| anyhow::anyhow!("no Stable channel found in chromedriver version response"))?
.version
.clone();
println!("chromedriver version: {}", version);
Ok(version)
}
fn assemble_chromedriver_url(chromedriver_version: &str, target: &str) -> String {
format!(
"https://chromedriver.storage.googleapis.com/{version}/chromedriver_{target}.zip",
"https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/{version}/{target}/chromedriver-{target}.zip",
version = chromedriver_version,
target = target,
)

Loading…
Cancel
Save