@@ -347,13 +347,12 @@ def uc_special_open_if_cf(
347
347
except Exception :
348
348
pass
349
349
if special :
350
+ time .sleep (0.05 )
350
351
with driver :
351
- time .sleep (0.18 )
352
352
driver .execute_script ('window.open("%s","_blank");' % url )
353
353
driver .close ()
354
- driver .switch_to .window (driver .window_handles [- 1 ])
355
- time .sleep (0.02 )
356
354
if mobile_emulator :
355
+ driver .switch_to .window (driver .window_handles [- 1 ])
357
356
uc_metrics = {}
358
357
if (
359
358
type (device_width ) is int
@@ -382,7 +381,8 @@ def uc_special_open_if_cf(
382
381
)
383
382
except Exception :
384
383
pass
385
- time .sleep (0.03 )
384
+ if not mobile_emulator :
385
+ driver .switch_to .window (driver .window_handles [- 1 ])
386
386
else :
387
387
driver .default_get (url ) # The original one
388
388
else :
@@ -392,23 +392,21 @@ def uc_special_open_if_cf(
392
392
393
393
def uc_open (driver , url ):
394
394
if (url .startswith ("http:" ) or url .startswith ("https:" )):
395
+ time .sleep (0.05 )
395
396
with driver :
396
- time .sleep (0.18 )
397
397
driver .default_get (url )
398
- time .sleep (0.02 )
399
398
else :
400
399
driver .default_get (url ) # The original one
401
400
return None
402
401
403
402
404
403
def uc_open_with_tab (driver , url ):
405
404
if (url .startswith ("http:" ) or url .startswith ("https:" )):
405
+ time .sleep (0.05 )
406
406
with driver :
407
- time .sleep (0.18 )
408
407
driver .execute_script ('window.open("%s","_blank");' % url )
409
408
driver .close ()
410
- driver .switch_to .window (driver .window_handles [- 1 ])
411
- time .sleep (0.02 )
409
+ driver .switch_to .window (driver .window_handles [- 1 ])
412
410
else :
413
411
driver .default_get (url ) # The original one
414
412
return None
@@ -2822,25 +2820,29 @@ def get_local_driver(
2822
2820
)
2823
2821
if headless2 :
2824
2822
try :
2825
- if use_version == "latest" or int (use_version ) >= 109 :
2823
+ if (
2824
+ use_version == "latest"
2825
+ or int (str (use_version ).split ("." )[0 ]) >= 109
2826
+ ):
2826
2827
chrome_options .add_argument ("--headless=new" )
2827
2828
else :
2828
2829
chrome_options .add_argument ("--headless=chrome" )
2829
2830
except Exception :
2830
2831
chrome_options .add_argument ("--headless=new" )
2831
2832
elif headless and undetectable :
2832
2833
try :
2833
- if int (use_version ) >= 109 :
2834
+ int_use_version = int (str (use_version ).split ("." )[0 ])
2835
+ if int_use_version >= 109 :
2834
2836
chrome_options .add_argument ("--headless=new" )
2835
2837
elif (
2836
- int ( use_version ) >= 96
2837
- and int ( use_version ) <= 108
2838
+ int_use_version >= 96
2839
+ and int_use_version <= 108
2838
2840
):
2839
2841
chrome_options .add_argument ("--headless=chrome" )
2840
2842
else :
2841
2843
pass # Will need Xvfb on Linux
2842
2844
except Exception :
2843
- pass
2845
+ pass # Will need Xvfb on Linux
2844
2846
elif headless :
2845
2847
if "--headless" not in chrome_options .arguments :
2846
2848
chrome_options .add_argument ("--headless" )
@@ -3117,6 +3119,13 @@ def get_local_driver(
3117
3119
and int (use_version ) >= 72
3118
3120
):
3119
3121
uc_chrome_version = int (use_version )
3122
+ elif (
3123
+ str (use_version ).split ("." )[0 ].isnumeric ()
3124
+ and int (str (use_version ).split ("." )[0 ]) >= 72
3125
+ ):
3126
+ uc_chrome_version = (
3127
+ int (str (use_version ).split ("." )[0 ])
3128
+ )
3120
3129
cdp_events = uc_cdp_events
3121
3130
cert = "unable to get local issuer certificate"
3122
3131
mac_certificate_error = False
@@ -3209,7 +3218,9 @@ def get_local_driver(
3209
3218
and use_version
3210
3219
and (
3211
3220
int (ch_driver_version )
3212
- < int (use_version )
3221
+ < int (str (
3222
+ use_version ).split ("." )[0 ]
3223
+ )
3213
3224
)
3214
3225
)
3215
3226
):
0 commit comments