[rust] Selenium-Manager fails when a browser detection fails with browser version
@@ -142,19 +142,27 @@ pub trait SeleniumManager {
.browsers
.push(create_browser_metadata(browser_name, &browser_version));
write_metadata(&metadata);
+ if !browser_version.is_empty() {
Some(browser_version)
+ } else {
+ None
+ }
}
}
}
- fn discover_driver_version(&mut self) -> String {
- if self.get_browser_version().is_empty() || self.is_browser_version_unstable() {
+ fn discover_driver_version(&mut self) -> Result<String, String> {
+ let browser_version = self.get_browser_version();
+ if browser_version.is_empty() || self.is_browser_version_unstable() {
match self.discover_browser_version() {
Some(version) => {
log::debug!("Detected browser: {} {}", self.get_browser_name(), version);
self.set_browser_version(version);
}
None => {
+ if self.is_browser_version_unstable() {
+ return Err(format!("Browser version '{browser_version}' not found"));
+ } else {
log::debug!(
"The version of {} cannot be detected. Trying with latest driver version",
self.get_browser_name()
@@ -162,6 +170,7 @@ pub trait SeleniumManager {
}
}
}
+ }
let driver_version = self
.request_driver_version()
.unwrap_or_else(|err| err.to_string());
@@ -170,7 +179,7 @@ pub trait SeleniumManager {
self.get_driver_name(),
driver_version
);
- driver_version
+ Ok(driver_version)
}
fn is_browser_version_unstable(&self) -> bool {
@@ -183,7 +192,7 @@ pub trait SeleniumManager {
fn resolve_driver(&mut self) -> Result<PathBuf, Box<dyn Error>> {
if self.get_driver_version().is_empty() {
- let driver_version = self.discover_driver_version();
+ let driver_version = self.discover_driver_version()?;
self.set_driver_version(driver_version);
}
