diff --git a/rust/src/chrome.rs b/rust/src/chrome.rs index f65dc46e2efc9..fb2506439ef63 100644 --- a/rust/src/chrome.rs +++ b/rust/src/chrome.rs @@ -521,18 +521,18 @@ impl SeleniumManager for ChromeManager { let good_versions_url = self.create_cft_url_for_browsers(GOOD_VERSIONS_ENDPOINT); let all_versions = self.request_versions_from_online::(&good_versions_url)?; - let filtered_versions: Vec = all_versions - .versions - .into_iter() - .filter(|r| r.version.starts_with(major_browser_version.as_str())) - .collect(); + let iter_versions = all_versions.versions.into_iter(); + let filtered_versions: Vec = if self.is_browser_version_specific() { + iter_versions + .filter(|r| r.version.eq(browser_version.as_str())) + .collect() + } else { + iter_versions + .filter(|r| r.version.starts_with(major_browser_version.as_str())) + .collect() + }; if filtered_versions.is_empty() { - return Err(anyhow!(format_three_args( - UNAVAILABLE_DOWNLOAD_WITH_MIN_VERSION_ERR_MSG, - browser_name, - &major_browser_version, - &MIN_CHROME_VERSION_CFT.to_string(), - ))); + return self.unavailable_download(); } let last_browser = filtered_versions.last().unwrap(); let platform_url: Vec<&PlatformUrl> = last_browser diff --git a/rust/src/lib.rs b/rust/src/lib.rs index 751f092029e6d..3df601e79bd2c 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -237,43 +237,47 @@ pub trait SeleniumManager { ))); } - // Browser version is checked in the local metadata - match get_browser_version_from_metadata( - &metadata.browsers, - self.get_browser_name(), - &major_browser_version, - ) { - Some(version) => { - self.get_logger().trace(format!( - "Browser with valid TTL. Getting {} version from metadata", - self.get_browser_name() - )); - browser_version = version; - self.set_browser_version(browser_version.clone()); - } - _ => { - // If not in metadata, discover version using online metadata - if self.is_browser_version_stable() || self.is_browser_version_empty() { - browser_version = - self.request_latest_browser_version_from_online(original_browser_version)?; - } else { - browser_version = - self.request_fixed_browser_version_from_online(original_browser_version)?; + if self.is_version_specific(original_browser_version) { + browser_version = original_browser_version.to_string(); + } else { + // Browser version is checked in the local metadata + match get_browser_version_from_metadata( + &metadata.browsers, + self.get_browser_name(), + &major_browser_version, + ) { + Some(version) => { + self.get_logger().trace(format!( + "Browser with valid TTL. Getting {} version from metadata", + self.get_browser_name() + )); + browser_version = version; + self.set_browser_version(browser_version.clone()); } - self.set_browser_version(browser_version.clone()); + _ => { + // If not in metadata, discover version using online metadata + if self.is_browser_version_stable() || self.is_browser_version_empty() { + browser_version = self + .request_latest_browser_version_from_online(original_browser_version)?; + } else { + browser_version = self + .request_fixed_browser_version_from_online(original_browser_version)?; + } + self.set_browser_version(browser_version.clone()); - let browser_ttl = self.get_ttl(); - if browser_ttl > 0 - && !self.is_browser_version_empty() - && !self.is_browser_version_stable() - { - metadata.browsers.push(create_browser_metadata( - self.get_browser_name(), - &major_browser_version, - &browser_version, - browser_ttl, - )); - write_metadata(&metadata, self.get_logger(), cache_path); + let browser_ttl = self.get_ttl(); + if browser_ttl > 0 + && !self.is_browser_version_empty() + && !self.is_browser_version_stable() + { + metadata.browsers.push(create_browser_metadata( + self.get_browser_name(), + &major_browser_version, + &browser_version, + browser_ttl, + )); + write_metadata(&metadata, self.get_logger(), cache_path); + } } } } @@ -715,6 +719,14 @@ pub trait SeleniumManager { self.is_stable(self.get_browser_version()) } + fn is_version_specific(&self, version: &str) -> bool { + version.contains(".") + } + + fn is_browser_version_specific(&self) -> bool { + self.is_version_specific(self.get_browser_version()) + } + fn setup(&mut self) -> Result { let mut driver_in_path = None; let mut driver_in_path_version = None; diff --git a/rust/tests/browser_download_tests.rs b/rust/tests/browser_download_tests.rs index 0c3329131725c..1259f2e4893bf 100644 --- a/rust/tests/browser_download_tests.rs +++ b/rust/tests/browser_download_tests.rs @@ -48,10 +48,13 @@ fn browser_latest_download_test(#[case] browser: String) { #[rstest] #[case("chrome", "113")] +#[case("chrome", "131.0.6725.0")] #[case("chrome", "beta")] #[case("firefox", "116")] +#[case("firefox", "121.0.1")] #[case("firefox", "beta")] #[case("firefox", "esr")] +#[case("edge", "129.0.2792.79")] #[case("edge", "beta")] fn browser_version_download_test(#[case] browser: String, #[case] browser_version: String) { if OS.eq("windows") && browser.eq("edge") {