@@ -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 :
@@ -95,7 +103,8 @@ def _add_chrome_proxy_extension(
95
103
""" Implementation of https://stackoverflow.com/a/35293284 for
96
104
https://stackoverflow.com/questions/12848327/
97
105
(Run Selenium on a proxy server that requires authentication.) """
98
- if not ("-n" in sys .argv or "" .join (sys .argv ) == "-c" ):
106
+ arg_join = " " .join (sys .argv )
107
+ if not ("-n" in sys .argv or "-n=" in arg_join or arg_join == "-c" ):
99
108
# Single-threaded
100
109
proxy_helper .create_proxy_zip (proxy_string , proxy_user , proxy_pass )
101
110
else :
@@ -229,7 +238,7 @@ def _create_firefox_profile(
229
238
profile .set_preference ("app.update.enabled" , False )
230
239
profile .set_preference ("app.update.silent" , True )
231
240
profile .set_preference ("browser.privatebrowsing.autostart" , True )
232
- profile .set_preference ("devtools.errorconsole.enabled" , True )
241
+ profile .set_preference ("devtools.errorconsole.enabled" , False )
233
242
profile .set_preference ("extensions.allowPrivateBrowsingByDefault" , True )
234
243
profile .set_preference ("extensions.PrivateBrowsing.notification" , False )
235
244
profile .set_preference ("extensions.systemAddon.update.enabled" , False )
@@ -410,7 +419,7 @@ def get_remote_driver(
410
419
for key in desired_caps .keys ():
411
420
firefox_capabilities [key ] = desired_caps [key ]
412
421
capabilities = firefox_capabilities
413
- address = "http://%s:%s/wd/hub" % ( servername , port )
422
+ warnings . simplefilter ( "ignore" , category = DeprecationWarning )
414
423
return webdriver .Remote (
415
424
command_executor = address ,
416
425
desired_capabilities = capabilities ,
@@ -529,7 +538,8 @@ def get_local_driver(
529
538
logging .debug ("\n Warning: Could not make geckodriver"
530
539
" executable: %s" % e )
531
540
elif not is_geckodriver_on_path ():
532
- if not ("-n" in sys .argv or "" .join (sys .argv ) == "-c" ):
541
+ args = " " .join (sys .argv )
542
+ if not ("-n" in sys .argv or "-n=" in args or args == "-c" ):
533
543
# (Not multithreaded)
534
544
from seleniumbase .console_scripts import sb_install
535
545
sys_args = sys .argv # Save a copy of current sys args
@@ -583,23 +593,40 @@ def get_local_driver(
583
593
" executable: %s" % e )
584
594
return webdriver .Ie (capabilities = ie_capabilities )
585
595
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
596
+ try :
593
597
chrome_options = _set_chrome_options (
594
598
downloads_path , headless ,
595
599
proxy_string , proxy_auth , proxy_user , proxy_pass , user_agent ,
596
600
disable_csp , enable_sync , incognito , user_data_dir ,
597
601
extension_zip , extension_dir , servername , mobile_emulator ,
598
602
device_width , device_height , device_pixel_ratio )
603
+ if LOCAL_EDGEDRIVER and os .path .exists (LOCAL_EDGEDRIVER ):
604
+ try :
605
+ make_driver_executable_if_not (LOCAL_EDGEDRIVER )
606
+ except Exception as e :
607
+ logging .debug ("\n Warning: Could not make edgedriver"
608
+ " executable: %s" % e )
609
+ elif not is_edgedriver_on_path ():
610
+ args = " " .join (sys .argv )
611
+ if not ("-n" in sys .argv or "-n=" in args or args == "-c" ):
612
+ # (Not multithreaded)
613
+ from seleniumbase .console_scripts import sb_install
614
+ sys_args = sys .argv # Save a copy of current sys args
615
+ print ("\n Warning: chromedriver not found. Installing now:" )
616
+ sb_install .main (override = "edgedriver" )
617
+ sys .argv = sys_args # Put back the original sys args
599
618
return webdriver .Chrome (executable_path = LOCAL_EDGEDRIVER ,
600
619
options = chrome_options )
601
- else :
602
- return webdriver .Edge ()
620
+ except Exception as e :
621
+ if headless :
622
+ raise Exception (e )
623
+ if LOCAL_EDGEDRIVER and os .path .exists (LOCAL_EDGEDRIVER ):
624
+ try :
625
+ make_driver_executable_if_not (LOCAL_EDGEDRIVER )
626
+ except Exception as e :
627
+ logging .debug ("\n Warning: Could not make edgedriver"
628
+ " executable: %s" % e )
629
+ return webdriver .Chrome (executable_path = LOCAL_EDGEDRIVER )
603
630
elif browser_name == constants .Browser .SAFARI :
604
631
arg_join = " " .join (sys .argv )
605
632
if ("-n" in sys .argv ) or ("-n=" in arg_join ) or (arg_join == "-c" ):
@@ -634,7 +661,8 @@ def get_local_driver(
634
661
logging .debug ("\n Warning: Could not make chromedriver"
635
662
" executable: %s" % e )
636
663
elif not is_chromedriver_on_path ():
637
- if not ("-n" in sys .argv or "" .join (sys .argv ) == "-c" ):
664
+ args = " " .join (sys .argv )
665
+ if not ("-n" in sys .argv or "-n=" in args or args == "-c" ):
638
666
# (Not multithreaded)
639
667
from seleniumbase .console_scripts import sb_install
640
668
sys_args = sys .argv # Save a copy of current sys args
0 commit comments