@@ -699,16 +699,47 @@ def get_local_driver(
699
699
sys .argv = sys_args # Put back the original sys args
700
700
return webdriver .Chrome (executable_path = LOCAL_EDGEDRIVER ,
701
701
options = chrome_options )
702
- except Exception as e :
703
- if headless :
704
- raise Exception (e )
702
+ except Exception :
703
+ from msedge .selenium_tools import Edge , EdgeOptions
705
704
if LOCAL_EDGEDRIVER and os .path .exists (LOCAL_EDGEDRIVER ):
706
705
try :
707
706
make_driver_executable_if_not (LOCAL_EDGEDRIVER )
708
707
except Exception as e :
709
708
logging .debug ("\n Warning: Could not make edgedriver"
710
709
" executable: %s" % e )
711
- return webdriver .Chrome (executable_path = LOCAL_EDGEDRIVER )
710
+ edge_options = EdgeOptions ()
711
+ edge_options .use_chromium = True
712
+ edge_options .add_experimental_option (
713
+ "useAutomationExtension" , False )
714
+ edge_options .add_experimental_option (
715
+ "excludeSwitches" , ["enable-automation" , "enable-logging" ])
716
+ if guest_mode :
717
+ edge_options .add_argument ("--guest" )
718
+ if headless :
719
+ edge_options .add_argument ("--headless" )
720
+ if mobile_emulator :
721
+ emulator_settings = {}
722
+ device_metrics = {}
723
+ if type (device_width ) is int and (
724
+ type (device_height ) is int and (
725
+ type (device_pixel_ratio ) is int )):
726
+ device_metrics ["width" ] = device_width
727
+ device_metrics ["height" ] = device_height
728
+ device_metrics ["pixelRatio" ] = device_pixel_ratio
729
+ else :
730
+ device_metrics ["width" ] = 411
731
+ device_metrics ["height" ] = 731
732
+ device_metrics ["pixelRatio" ] = 3
733
+ emulator_settings ["deviceMetrics" ] = device_metrics
734
+ if user_agent :
735
+ emulator_settings ["userAgent" ] = user_agent
736
+ edge_options .add_experimental_option (
737
+ "mobileEmulation" , emulator_settings )
738
+ edge_options .add_argument ("--enable-sync" )
739
+ capabilities = edge_options .to_capabilities ()
740
+ capabilities ["platform" ] = ''
741
+ return Edge (
742
+ executable_path = LOCAL_EDGEDRIVER , capabilities = capabilities )
712
743
elif browser_name == constants .Browser .SAFARI :
713
744
arg_join = " " .join (sys .argv )
714
745
if ("-n" in sys .argv ) or ("-n=" in arg_join ) or (arg_join == "-c" ):
0 commit comments