Skip to content

Commit

Permalink
[rust] Return complete safari and safaritp browser path (#12434)
Browse files Browse the repository at this point in the history
  • Loading branch information
bonigarcia authored Jul 31, 2023
1 parent c0317a5 commit 3926580
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
8 changes: 4 additions & 4 deletions rust/src/safari.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ use crate::{create_http_client, format_one_arg, Logger, SeleniumManager, PLIST_C

pub const SAFARI_NAME: &str = "safari";
pub const SAFARIDRIVER_NAME: &str = "safaridriver";
const SAFARI_PATH: &str = r#"/Applications/Safari.app"#;
const SAFARI_FULL_PATH: &str = r#"/Applications/Safari.app/Contents/MacOS/Safari"#;

pub struct SafariManager {
pub browser_name: &'static str,
Expand Down Expand Up @@ -69,10 +71,7 @@ impl SeleniumManager for SafariManager {
}

fn get_browser_path_map(&self) -> HashMap<BrowserPath, &str> {
HashMap::from([(
BrowserPath::new(MACOS, STABLE),
r#"/Applications/Safari.app"#,
)])
HashMap::from([(BrowserPath::new(MACOS, STABLE), SAFARI_PATH)])
}

fn discover_browser_version(&mut self) -> Option<String> {
Expand All @@ -90,6 +89,7 @@ impl SeleniumManager for SafariManager {
} else {
return None;
};
self.set_browser_path(SAFARI_FULL_PATH.to_string());
self.detect_browser_version(command)
}

Expand Down
9 changes: 5 additions & 4 deletions rust/src/safaritp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ pub const SAFARITP_NAMES: &[&str] = &[
"safaritechnologypreview",
];
pub const SAFARITPDRIVER_NAME: &str = "safaridriver";
const SAFARITP_PATH: &str = r#"/Applications/Safari Technology Preview.app"#;
const SAFARITP_FULL_PATH: &str =
r#"/Applications/Safari Technology Preview.app/Contents/MacOS/Safari Technology Preview"#;

pub struct SafariTPManager {
pub browser_name: &'static str,
Expand Down Expand Up @@ -74,10 +77,7 @@ impl SeleniumManager for SafariTPManager {
}

fn get_browser_path_map(&self) -> HashMap<BrowserPath, &str> {
HashMap::from([(
BrowserPath::new(MACOS, STABLE),
r#"/Applications/Safari\ Technology\ Preview.app"#,
)])
HashMap::from([(BrowserPath::new(MACOS, STABLE), SAFARITP_PATH)])
}

fn discover_browser_version(&mut self) -> Option<String> {
Expand All @@ -95,6 +95,7 @@ impl SeleniumManager for SafariTPManager {
} else {
return None;
};
self.set_browser_path(SAFARITP_FULL_PATH.to_string());
self.detect_browser_version(command)
}

Expand Down

0 comments on commit 3926580

Please sign in to comment.