@@ -666,11 +666,9 @@ def _set_chrome_options(
666666 chrome_options = webdriver .ChromeOptions ()
667667 if is_using_uc (undetectable , browser_name ):
668668 from seleniumbase import undetected
669-
670669 chrome_options = undetected .ChromeOptions ()
671670 elif browser_name == constants .Browser .EDGE :
672671 chrome_options = webdriver .edge .options .Options ()
673-
674672 prefs = {}
675673 prefs ["download.default_directory" ] = downloads_path
676674 prefs ["local_discovery.notifications_enabled" ] = False
@@ -2485,12 +2483,12 @@ def get_local_driver(
24852483 binary_location = binary_loc
24862484 if binary_location :
24872485 edge_options .binary_location = binary_location
2486+ service = EdgeService (
2487+ executable_path = LOCAL_EDGEDRIVER ,
2488+ log_output = os .devnull ,
2489+ service_args = ["--disable-build-check" ],
2490+ )
24882491 try :
2489- service = EdgeService (
2490- executable_path = LOCAL_EDGEDRIVER ,
2491- log_output = os .devnull ,
2492- service_args = ["--disable-build-check" ],
2493- )
24942492 driver = Edge (service = service , options = edge_options )
24952493 except Exception as e :
24962494 if not hasattr (e , "msg" ):
@@ -2512,11 +2510,6 @@ def get_local_driver(
25122510 "only supports MSEdge version "
25132511 )[1 ].split (" " )[0 ]
25142512 elif "DevToolsActivePort file doesn't exist" in e .msg :
2515- service = EdgeService (
2516- executable_path = LOCAL_EDGEDRIVER ,
2517- log_output = os .devnull ,
2518- service_args = ["--disable-build-check" ],
2519- )
25202513 # https://stackoverflow.com/a/56638103/7058266
25212514 args = " " .join (sys .argv )
25222515 free_port = 9222
@@ -2550,11 +2543,6 @@ def get_local_driver(
25502543 _mark_driver_repaired ()
25512544 except Exception :
25522545 pass
2553- service = EdgeService (
2554- executable_path = LOCAL_EDGEDRIVER ,
2555- log_output = os .devnull ,
2556- service_args = ["--disable-build-check" ],
2557- )
25582546 driver = Edge (service = service , options = edge_options )
25592547 return extend_driver (driver )
25602548 elif browser_name == constants .Browser .SAFARI :
@@ -3019,6 +3007,99 @@ def get_local_driver(
30193007 chrome_options .add_experimental_option (
30203008 "w3c" , True
30213009 )
3010+ try :
3011+ if (
3012+ uc_chrome_version
3013+ and uc_chrome_version >= 117
3014+ and (headless or headless2 )
3015+ and not user_agent
3016+ ):
3017+ headless_options = _set_chrome_options (
3018+ browser_name ,
3019+ downloads_path ,
3020+ True , # headless
3021+ locale_code ,
3022+ proxy_string ,
3023+ proxy_auth ,
3024+ proxy_user ,
3025+ proxy_pass ,
3026+ proxy_bypass_list ,
3027+ proxy_pac_url ,
3028+ multi_proxy ,
3029+ user_agent ,
3030+ recorder_ext ,
3031+ disable_js ,
3032+ disable_csp ,
3033+ enable_ws ,
3034+ enable_sync ,
3035+ use_auto_ext ,
3036+ False , # Undetectable
3037+ uc_cdp_events ,
3038+ uc_subprocess ,
3039+ no_sandbox ,
3040+ disable_gpu ,
3041+ False , # headless2
3042+ incognito ,
3043+ guest_mode ,
3044+ dark_mode ,
3045+ devtools ,
3046+ remote_debug ,
3047+ enable_3d_apis ,
3048+ swiftshader ,
3049+ ad_block_on ,
3050+ block_images ,
3051+ do_not_track ,
3052+ chromium_arg ,
3053+ user_data_dir ,
3054+ extension_zip ,
3055+ extension_dir ,
3056+ binary_location ,
3057+ driver_version ,
3058+ page_load_strategy ,
3059+ use_wire ,
3060+ external_pdf ,
3061+ servername ,
3062+ mobile_emulator ,
3063+ device_width ,
3064+ device_height ,
3065+ device_pixel_ratio ,
3066+ )
3067+ if not path_chromedriver :
3068+ sb_install .main (
3069+ override = "chromedriver %s"
3070+ % use_version ,
3071+ intel_for_uc = False ,
3072+ force_uc = False ,
3073+ )
3074+ d_b_c = "--disable-build-check"
3075+ if os .path .exists (LOCAL_CHROMEDRIVER ):
3076+ service = ChromeService (
3077+ executable_path = LOCAL_CHROMEDRIVER ,
3078+ log_output = os .devnull ,
3079+ service_args = [d_b_c ],
3080+ )
3081+ driver = webdriver .Chrome (
3082+ service = service ,
3083+ options = headless_options ,
3084+ )
3085+ else :
3086+ service = ChromeService (
3087+ log_output = os .devnull ,
3088+ service_args = [d_b_c ],
3089+ )
3090+ driver = webdriver .Chrome (
3091+ service = service ,
3092+ options = headless_options ,
3093+ )
3094+ user_agent = driver .execute_script (
3095+ "return navigator.userAgent;"
3096+ ).replace ("Headless" , "" )
3097+ chrome_options .add_argument (
3098+ "--user-agent=%s" % user_agent
3099+ )
3100+ driver .quit ()
3101+ except Exception :
3102+ pass
30223103 try :
30233104 uc_path = None
30243105 if os .path .exists (LOCAL_UC_DRIVER ):
0 commit comments