MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / setup

Method setup

rust/src/lib.rs:872–989  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

870 }
871
872 fn setup(&mut self) -> Result<PathBuf, Error> {
873 let mut driver_in_path = None;
874 let mut driver_in_path_version = None;
875 let original_browser_version = self.get_config().browser_version.clone();
876
877 // Try to find driver in PATH
878 if !self.is_safari() && !self.is_grid() && !self.is_electron() {
879 self.get_logger()
880 .trace(format!("Checking {} in PATH", self.get_driver_name()));
881 (driver_in_path_version, driver_in_path) = self.find_driver_in_path();
882 if let (Some(version), Some(path)) = (&driver_in_path_version, &driver_in_path) {
883 self.get_logger().debug(format!(
884 "Found {} {} in PATH: {}",
885 self.get_driver_name(),
886 version,
887 path
888 ));
889 } else {
890 self.get_logger()
891 .debug(format!("{} not found in PATH", self.get_driver_name()));
892 }
893 }
894 let use_driver_in_path = driver_in_path_version.is_some()
895 && driver_in_path.is_some()
896 && original_browser_version.is_empty();
897
898 // Discover browser version (or the need to download it, if not available and possible)
899 match self.discover_local_browser() {
900 Ok(_) => {}
901 Err(err) => self.check_error_with_driver_in_path(&use_driver_in_path, err)?,
902 }
903
904 // Download browser if necessary
905 match self.download_browser_if_necessary(&original_browser_version) {
906 Ok(_) => {}
907 Err(err) => {
908 self.set_fallback_driver_from_cache(false);
909 self.check_error_with_driver_in_path(&use_driver_in_path, err)?
910 }
911 }
912
913 // With the discovered browser version, discover the proper driver version using online endpoints
914 if self.get_driver_version().is_empty()
915 || (self.is_grid() && self.is_nightly(self.get_driver_version()))
916 {
917 match self.discover_driver_version() {
918 Ok(driver_version) => {
919 self.set_driver_version(driver_version);
920 }
921 Err(err) => self.check_error_with_driver_in_path(&use_driver_in_path, err)?,
922 }
923 }
924
925 // Use driver in PATH when the user has not specified any browser version
926 if use_driver_in_path {
927 let path = driver_in_path.unwrap();
928
929 if self.is_skip_driver_in_path() {

Callers 1

mainFunction · 0.45

Implementers 8

edge.rsrust/src/edge.rs
iexplorer.rsrust/src/iexplorer.rs
safaritp.rsrust/src/safaritp.rs
electron.rsrust/src/electron.rs
chrome.rsrust/src/chrome.rs
firefox.rsrust/src/firefox.rs
grid.rsrust/src/grid.rs
safari.rsrust/src/safari.rs

Calls 15

get_metadataFunction · 0.85
update_cached_assetFunction · 0.85
write_metadataFunction · 0.85
is_safariMethod · 0.80
is_gridMethod · 0.80
is_electronMethod · 0.80
traceMethod · 0.80
find_driver_in_pathMethod · 0.80
is_emptyMethod · 0.80

Tested by

no test coverage detected