@@ -666,11 +666,9 @@ def _set_chrome_options(
666
666
chrome_options = webdriver .ChromeOptions ()
667
667
if is_using_uc (undetectable , browser_name ):
668
668
from seleniumbase import undetected
669
-
670
669
chrome_options = undetected .ChromeOptions ()
671
670
elif browser_name == constants .Browser .EDGE :
672
671
chrome_options = webdriver .edge .options .Options ()
673
-
674
672
prefs = {}
675
673
prefs ["download.default_directory" ] = downloads_path
676
674
prefs ["local_discovery.notifications_enabled" ] = False
@@ -2485,12 +2483,12 @@ def get_local_driver(
2485
2483
binary_location = binary_loc
2486
2484
if binary_location :
2487
2485
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
+ )
2488
2491
try :
2489
- service = EdgeService (
2490
- executable_path = LOCAL_EDGEDRIVER ,
2491
- log_output = os .devnull ,
2492
- service_args = ["--disable-build-check" ],
2493
- )
2494
2492
driver = Edge (service = service , options = edge_options )
2495
2493
except Exception as e :
2496
2494
if not hasattr (e , "msg" ):
@@ -2512,11 +2510,6 @@ def get_local_driver(
2512
2510
"only supports MSEdge version "
2513
2511
)[1 ].split (" " )[0 ]
2514
2512
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
- )
2520
2513
# https://stackoverflow.com/a/56638103/7058266
2521
2514
args = " " .join (sys .argv )
2522
2515
free_port = 9222
@@ -2550,11 +2543,6 @@ def get_local_driver(
2550
2543
_mark_driver_repaired ()
2551
2544
except Exception :
2552
2545
pass
2553
- service = EdgeService (
2554
- executable_path = LOCAL_EDGEDRIVER ,
2555
- log_output = os .devnull ,
2556
- service_args = ["--disable-build-check" ],
2557
- )
2558
2546
driver = Edge (service = service , options = edge_options )
2559
2547
return extend_driver (driver )
2560
2548
elif browser_name == constants .Browser .SAFARI :
@@ -3019,6 +3007,99 @@ def get_local_driver(
3019
3007
chrome_options .add_experimental_option (
3020
3008
"w3c" , True
3021
3009
)
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
3022
3103
try :
3023
3104
uc_path = None
3024
3105
if os .path .exists (LOCAL_UC_DRIVER ):
0 commit comments