Skip to content

Commit

Permalink
[rust] Read LATEST_STABLE and then LATEST_RELEASE for msedgedriver in…
Browse files Browse the repository at this point in the history
… latest fallback
  • Loading branch information
bonigarcia committed Apr 21, 2023
1 parent e51d1aa commit 9c2f475
Showing 1 changed file with 31 additions and 15 deletions.
46 changes: 31 additions & 15 deletions rust/src/edge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,15 @@ impl SeleniumManager for EdgeManager {
}

fn request_driver_version(&self) -> Result<String, Box<dyn Error>> {
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",
Expand All @@ -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
Expand All @@ -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,
Expand Down

0 comments on commit 9c2f475

Please sign in to comment.