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

Method setup

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

Source from the content-addressed store, hash-verified

848 }
849
850 fn setup(&mut self) -> Result<PathBuf, Error> {
851 let mut driver_in_path = None;
852 let mut driver_in_path_version = None;
853 let original_browser_version = self.get_config().browser_version.clone();
854
855 // Try to find driver in PATH
856 if !self.is_safari() && !self.is_grid() && !self.is_electron() {
857 self.get_logger()
858 .trace(format!("Checking {} in PATH", self.get_driver_name()));
859 (driver_in_path_version, driver_in_path) = self.find_driver_in_path();
860 if let (Some(version), Some(path)) = (&driver_in_path_version, &driver_in_path) {
861 self.get_logger().debug(format!(
862 "Found {} {} in PATH: {}",
863 self.get_driver_name(),
864 version,
865 path
866 ));
867 } else {
868 self.get_logger()
869 .debug(format!("{} not found in PATH", self.get_driver_name()));
870 }
871 }
872 let use_driver_in_path = driver_in_path_version.is_some()
873 && driver_in_path.is_some()
874 && original_browser_version.is_empty();
875
876 // Discover browser version (or the need to download it, if not available and possible)
877 match self.discover_local_browser() {
878 Ok(_) => {}
879 Err(err) => self.check_error_with_driver_in_path(&use_driver_in_path, err)?,
880 }
881
882 // Download browser if necessary
883 match self.download_browser_if_necessary(&original_browser_version) {
884 Ok(_) => {}
885 Err(err) => {
886 self.set_fallback_driver_from_cache(false);
887 self.check_error_with_driver_in_path(&use_driver_in_path, err)?
888 }
889 }
890
891 // With the discovered browser version, discover the proper driver version using online endpoints
892 if self.get_driver_version().is_empty()
893 || (self.is_grid() && self.is_nightly(self.get_driver_version()))
894 {
895 match self.discover_driver_version() {
896 Ok(driver_version) => {
897 self.set_driver_version(driver_version);
898 }
899 Err(err) => self.check_error_with_driver_in_path(&use_driver_in_path, err)?,
900 }
901 }
902
903 // Use driver in PATH when the user has not specified any browser version
904 if use_driver_in_path {
905 let path = driver_in_path.unwrap();
906
907 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