@@ -73,6 +73,22 @@ def make_driver_executable_if_not(driver_path):
73
73
make_executable (driver_path )
74
74
75
75
76
+ def is_chromedriver_on_path ():
77
+ paths = os .environ ["PATH" ].split (os .pathsep )
78
+ for path in paths :
79
+ if os .path .exists (path + '/' + "chromedriver" ):
80
+ return True
81
+ return False
82
+
83
+
84
+ def is_geckodriver_on_path ():
85
+ paths = os .environ ["PATH" ].split (os .pathsep )
86
+ for path in paths :
87
+ if os .path .exists (path + '/' + "geckodriver" ):
88
+ return True
89
+ return False
90
+
91
+
76
92
def _add_chrome_proxy_extension (
77
93
chrome_options , proxy_string , proxy_user , proxy_pass ):
78
94
""" Implementation of https://stackoverflow.com/a/35293284 for
@@ -474,6 +490,14 @@ def get_local_driver(
474
490
options .add_argument ('-headless' )
475
491
if LOCAL_GECKODRIVER and os .path .exists (LOCAL_GECKODRIVER ):
476
492
make_driver_executable_if_not (LOCAL_GECKODRIVER )
493
+ elif not is_geckodriver_on_path ():
494
+ if not "" .join (sys .argv ) == "-c" : # Skip if multithreaded
495
+ from seleniumbase .console_scripts import sb_install
496
+ sys_args = sys .argv # Save a copy of current sys args
497
+ print ("\n Warning: geckodriver not found."
498
+ " Installing now:" )
499
+ sb_install .main (override = "geckodriver" )
500
+ sys .argv = sys_args # Put back the original sys args
477
501
firefox_driver = webdriver .Firefox (
478
502
firefox_profile = profile ,
479
503
capabilities = firefox_capabilities ,
@@ -540,6 +564,13 @@ def get_local_driver(
540
564
extension_zip , extension_dir )
541
565
if LOCAL_CHROMEDRIVER and os .path .exists (LOCAL_CHROMEDRIVER ):
542
566
make_driver_executable_if_not (LOCAL_CHROMEDRIVER )
567
+ elif not is_chromedriver_on_path ():
568
+ if not "" .join (sys .argv ) == "-c" : # Skip if multithreaded
569
+ from seleniumbase .console_scripts import sb_install
570
+ sys_args = sys .argv # Save a copy of current sys args
571
+ print ("\n Warning: chromedriver not found. Installing now:" )
572
+ sb_install .main (override = "chromedriver" )
573
+ sys .argv = sys_args # Put back the original sys args
543
574
return webdriver .Chrome (options = chrome_options )
544
575
except Exception as e :
545
576
if headless :
0 commit comments