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

Method setup

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

Source from the content-addressed store, hash-verified

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