(&mut self)
| 427 | } |
| 428 | |
| 429 | fn detect_browser_path(&mut self) -> Option<PathBuf> { |
| 430 | // A driver's binary search is channel-agnostic and finds system browsers, so mirror it only |
| 431 | // for the default channel and when the user hasn't asked to skip browsers in the path. |
| 432 | if !self.is_browser_version_unstable() |
| 433 | && !self.is_skip_browser_in_path() |
| 434 | && let Some(browser_path) = self.detect_browser_in_known_locations() |
| 435 | { |
| 436 | let canon_browser_path = self.canonicalize_path(browser_path); |
| 437 | self.get_logger().debug(format!( |
| 438 | "{} detected at {}", |
| 439 | self.get_browser_name(), |
| 440 | canon_browser_path |
| 441 | )); |
| 442 | self.set_browser_path(canon_browser_path.clone()); |
| 443 | return Some(Path::new(&canon_browser_path).to_path_buf()); |
| 444 | } |
| 445 | |
| 446 | let browser_version = self.get_browser_version(); |
| 447 | let browser_path = self.get_browser_path_from_version(browser_version); |
| 448 | |
| 449 | let mut full_browser_path = Path::new(browser_path).to_path_buf(); |
| 450 | if WINDOWS.is(self.get_os()) { |
| 451 | let envs = vec![ENV_PROGRAM_FILES, ENV_PROGRAM_FILES_X86, ENV_LOCALAPPDATA]; |
| 452 | |
| 453 | for env in envs { |
| 454 | let mut env_value = env::var(env).unwrap_or_default(); |
| 455 | if env.eq(ENV_PROGRAM_FILES) && env_value.contains(ENV_X86) { |
| 456 | // This special case is required to keep compliance between x32 and x64 |
| 457 | // architectures (since the selenium-manager in Windows is compiled as x32 binary) |
| 458 | env_value = env_value.replace(ENV_X86, ""); |
| 459 | } |
| 460 | let parent_path = Path::new(&env_value); |
| 461 | full_browser_path = parent_path.join(browser_path); |
| 462 | if full_browser_path.exists() { |
| 463 | break; |
| 464 | } |
| 465 | } |
| 466 | } |
| 467 | |
| 468 | if full_browser_path.exists() { |
| 469 | let canon_browser_path = self.canonicalize_path(full_browser_path); |
| 470 | self.get_logger().debug(format!( |
| 471 | "{} detected at {}", |
| 472 | self.get_browser_name(), |
| 473 | canon_browser_path |
| 474 | )); |
| 475 | self.set_browser_path(canon_browser_path.clone()); |
| 476 | |
| 477 | Some(Path::new(&canon_browser_path).to_path_buf()) |
| 478 | } else { |
| 479 | // Check browser in PATH |
| 480 | let browser_in_path = self.find_browser_in_path(); |
| 481 | if let Some(path) = &browser_in_path { |
| 482 | if self.is_skip_browser_in_path() { |
| 483 | self.get_logger().debug(format!( |
| 484 | "Skipping {} in path: {}", |
| 485 | self.get_browser_name(), |
| 486 | path.display() |
no test coverage detected