Skip to content

Commit 3a87306

Browse files
authored
[rust] Implement browser path discovery in IExplorer (#12489)
1 parent 3df8b70 commit 3a87306

File tree

1 file changed

+31
-4
lines changed

1 file changed

+31
-4
lines changed

rust/src/iexplorer.rs

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@ use std::collections::HashMap;
2121
use std::error::Error;
2222
use std::path::PathBuf;
2323

24-
use crate::files::{compose_driver_path_in_cache, BrowserPath};
24+
use crate::files::{compose_driver_path_in_cache, path_buf_to_string, BrowserPath};
2525

2626
use crate::downloads::parse_json_from_url;
2727
use crate::{
28-
create_http_client, parse_version, Logger, SeleniumManager, OFFLINE_REQUEST_ERR_MSG, WINDOWS,
28+
create_http_client, format_one_arg, parse_version, Logger, SeleniumManager,
29+
OFFLINE_REQUEST_ERR_MSG, REG_QUERY, STABLE, WINDOWS, WMIC_COMMAND,
2930
};
3031

3132
use crate::metadata::{
@@ -87,11 +88,37 @@ impl SeleniumManager for IExplorerManager {
8788
}
8889

8990
fn get_browser_path_map(&self) -> HashMap<BrowserPath, &str> {
90-
HashMap::new()
91+
HashMap::from([(
92+
BrowserPath::new(WINDOWS, STABLE),
93+
r#"Internet Explorer\iexplore.exe"#,
94+
)])
9195
}
9296

9397
fn discover_browser_version(&mut self) -> Option<String> {
94-
None
98+
let commands;
99+
let mut browser_path = self.get_browser_path().to_string();
100+
let escaped_browser_path;
101+
if browser_path.is_empty() {
102+
match self.detect_browser_path() {
103+
Some(path) => {
104+
browser_path = path_buf_to_string(path);
105+
escaped_browser_path = self.get_escaped_path(browser_path.to_string());
106+
commands = vec![format_one_arg(WMIC_COMMAND, &escaped_browser_path)];
107+
}
108+
None => {
109+
commands = vec![
110+
(format_one_arg(
111+
REG_QUERY,
112+
r#"HKEY_LOCAL_MACHINE\Software\Microsoft\Internet Explorer"#,
113+
)),
114+
];
115+
}
116+
}
117+
} else {
118+
escaped_browser_path = self.get_escaped_path(browser_path.to_string());
119+
commands = vec![format_one_arg(WMIC_COMMAND, &escaped_browser_path)];
120+
}
121+
self.detect_browser_version(commands)
95122
}
96123

97124
fn get_driver_name(&self) -> &str {

0 commit comments

Comments
 (0)