@@ -82,6 +82,14 @@ def is_chromedriver_on_path():
82
82
return False
83
83
84
84
85
+ def is_edgedriver_on_path ():
86
+ paths = os .environ ["PATH" ].split (os .pathsep )
87
+ for path in paths :
88
+ if os .path .exists (path + '/' + "msedgedriver" ):
89
+ return True
90
+ return False
91
+
92
+
85
93
def is_geckodriver_on_path ():
86
94
paths = os .environ ["PATH" ].split (os .pathsep )
87
95
for path in paths :
@@ -583,23 +591,39 @@ def get_local_driver(
583
591
" executable: %s" % e )
584
592
return webdriver .Ie (capabilities = ie_capabilities )
585
593
elif browser_name == constants .Browser .EDGE :
586
- if LOCAL_EDGEDRIVER and os .path .exists (LOCAL_EDGEDRIVER ):
587
- try :
588
- make_driver_executable_if_not (LOCAL_EDGEDRIVER )
589
- except Exception as e :
590
- logging .debug ("\n Warning: Could not make edgedriver"
591
- " executable: %s" % e )
592
- # The new Microsoft Edge browser is based on Chromium
594
+ try :
593
595
chrome_options = _set_chrome_options (
594
596
downloads_path , headless ,
595
597
proxy_string , proxy_auth , proxy_user , proxy_pass , user_agent ,
596
598
disable_csp , enable_sync , incognito , user_data_dir ,
597
599
extension_zip , extension_dir , servername , mobile_emulator ,
598
600
device_width , device_height , device_pixel_ratio )
601
+ if LOCAL_EDGEDRIVER and os .path .exists (LOCAL_EDGEDRIVER ):
602
+ try :
603
+ make_driver_executable_if_not (LOCAL_EDGEDRIVER )
604
+ except Exception as e :
605
+ logging .debug ("\n Warning: Could not make edgedriver"
606
+ " executable: %s" % e )
607
+ elif not is_edgedriver_on_path ():
608
+ if not ("-n" in sys .argv or "" .join (sys .argv ) == "-c" ):
609
+ # (Not multithreaded)
610
+ from seleniumbase .console_scripts import sb_install
611
+ sys_args = sys .argv # Save a copy of current sys args
612
+ print ("\n Warning: chromedriver not found. Installing now:" )
613
+ sb_install .main (override = "edgedriver" )
614
+ sys .argv = sys_args # Put back the original sys args
599
615
return webdriver .Chrome (executable_path = LOCAL_EDGEDRIVER ,
600
616
options = chrome_options )
601
- else :
602
- return webdriver .Edge ()
617
+ except Exception as e :
618
+ if headless :
619
+ raise Exception (e )
620
+ if LOCAL_EDGEDRIVER and os .path .exists (LOCAL_EDGEDRIVER ):
621
+ try :
622
+ make_driver_executable_if_not (LOCAL_EDGEDRIVER )
623
+ except Exception as e :
624
+ logging .debug ("\n Warning: Could not make edgedriver"
625
+ " executable: %s" % e )
626
+ return webdriver .Chrome (executable_path = LOCAL_EDGEDRIVER )
603
627
elif browser_name == constants .Browser .SAFARI :
604
628
arg_join = " " .join (sys .argv )
605
629
if ("-n" in sys .argv ) or ("-n=" in arg_join ) or (arg_join == "-c" ):
0 commit comments