@@ -82,6 +82,14 @@ def is_chromedriver_on_path():
8282 return False
8383
8484
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+
8593def is_geckodriver_on_path ():
8694 paths = os .environ ["PATH" ].split (os .pathsep )
8795 for path in paths :
@@ -95,7 +103,8 @@ def _add_chrome_proxy_extension(
95103 """ Implementation of https://stackoverflow.com/a/35293284 for
96104 https://stackoverflow.com/questions/12848327/
97105 (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" ):
99108 # Single-threaded
100109 proxy_helper .create_proxy_zip (proxy_string , proxy_user , proxy_pass )
101110 else :
@@ -229,7 +238,7 @@ def _create_firefox_profile(
229238 profile .set_preference ("app.update.enabled" , False )
230239 profile .set_preference ("app.update.silent" , True )
231240 profile .set_preference ("browser.privatebrowsing.autostart" , True )
232- profile .set_preference ("devtools.errorconsole.enabled" , True )
241+ profile .set_preference ("devtools.errorconsole.enabled" , False )
233242 profile .set_preference ("extensions.allowPrivateBrowsingByDefault" , True )
234243 profile .set_preference ("extensions.PrivateBrowsing.notification" , False )
235244 profile .set_preference ("extensions.systemAddon.update.enabled" , False )
@@ -410,7 +419,7 @@ def get_remote_driver(
410419 for key in desired_caps .keys ():
411420 firefox_capabilities [key ] = desired_caps [key ]
412421 capabilities = firefox_capabilities
413- address = "http://%s:%s/wd/hub" % ( servername , port )
422+ warnings . simplefilter ( "ignore" , category = DeprecationWarning )
414423 return webdriver .Remote (
415424 command_executor = address ,
416425 desired_capabilities = capabilities ,
@@ -529,7 +538,8 @@ def get_local_driver(
529538 logging .debug ("\n Warning: Could not make geckodriver"
530539 " executable: %s" % e )
531540 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" ):
533543 # (Not multithreaded)
534544 from seleniumbase .console_scripts import sb_install
535545 sys_args = sys .argv # Save a copy of current sys args
@@ -583,23 +593,40 @@ def get_local_driver(
583593 " executable: %s" % e )
584594 return webdriver .Ie (capabilities = ie_capabilities )
585595 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 :
593597 chrome_options = _set_chrome_options (
594598 downloads_path , headless ,
595599 proxy_string , proxy_auth , proxy_user , proxy_pass , user_agent ,
596600 disable_csp , enable_sync , incognito , user_data_dir ,
597601 extension_zip , extension_dir , servername , mobile_emulator ,
598602 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
599618 return webdriver .Chrome (executable_path = LOCAL_EDGEDRIVER ,
600619 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 )
603630 elif browser_name == constants .Browser .SAFARI :
604631 arg_join = " " .join (sys .argv )
605632 if ("-n" in sys .argv ) or ("-n=" in arg_join ) or (arg_join == "-c" ):
@@ -634,7 +661,8 @@ def get_local_driver(
634661 logging .debug ("\n Warning: Could not make chromedriver"
635662 " executable: %s" % e )
636663 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" ):
638666 # (Not multithreaded)
639667 from seleniumbase .console_scripts import sb_install
640668 sys_args = sys .argv # Save a copy of current sys args
0 commit comments