diff --git a/rust/src/edge.rs b/rust/src/edge.rs index 55e2bbf7a5790..8e7f14054a695 100644 --- a/rust/src/edge.rs +++ b/rust/src/edge.rs @@ -163,12 +163,15 @@ impl SeleniumManager for EdgeManager { } fn request_driver_version(&self) -> Result> { - let browser_version = self.get_browser_version(); + let mut browser_version = self.get_browser_version().to_string(); let mut metadata = get_metadata(self.get_logger()); let driver_ttl = self.get_config().driver_ttl; - match get_driver_version_from_metadata(&metadata.drivers, self.driver_name, browser_version) - { + match get_driver_version_from_metadata( + &metadata.drivers, + self.driver_name, + browser_version.as_str(), + ) { Some(driver_version) => { self.log.trace(format!( "Driver TTL is valid. Getting {} version from metadata", @@ -177,17 +180,30 @@ impl SeleniumManager for EdgeManager { Ok(driver_version) } _ => { - let driver_url = if browser_version.is_empty() { - format!("{}{}", DRIVER_URL, LATEST_STABLE) - } else { - format!( - "{}{}_{}_{}", - DRIVER_URL, - LATEST_RELEASE, - browser_version, - self.get_os().to_uppercase() - ) - }; + if browser_version.is_empty() { + let latest_stable_url = format!("{}{}", DRIVER_URL, LATEST_STABLE); + self.log.debug(format!( + "Reading {} latest version from {}", + &self.driver_name, latest_stable_url + )); + let latest_driver_version = read_version_from_link( + self.get_http_client(), + latest_stable_url, + self.get_logger(), + )?; + browser_version = self.get_major_version(latest_driver_version.as_str())?; + self.log.debug(format!( + "Latest {} major version is {}", + &self.driver_name, browser_version + )); + } + let driver_url = format!( + "{}{}_{}_{}", + DRIVER_URL, + LATEST_RELEASE, + browser_version, + self.get_os().to_uppercase() + ); self.log.debug(format!( "Reading {} version from {}", &self.driver_name, driver_url @@ -197,7 +213,7 @@ impl SeleniumManager for EdgeManager { if !browser_version.is_empty() { metadata.drivers.push(create_driver_metadata( - browser_version, + browser_version.as_str(), self.driver_name, &driver_version, driver_ttl,