@@ -347,13 +347,12 @@ def uc_special_open_if_cf(
347347 except Exception :
348348 pass
349349 if special :
350+ time .sleep (0.05 )
350351 with driver :
351- time .sleep (0.18 )
352352 driver .execute_script ('window.open("%s","_blank");' % url )
353353 driver .close ()
354- driver .switch_to .window (driver .window_handles [- 1 ])
355- time .sleep (0.02 )
356354 if mobile_emulator :
355+ driver .switch_to .window (driver .window_handles [- 1 ])
357356 uc_metrics = {}
358357 if (
359358 type (device_width ) is int
@@ -382,7 +381,8 @@ def uc_special_open_if_cf(
382381 )
383382 except Exception :
384383 pass
385- time .sleep (0.03 )
384+ if not mobile_emulator :
385+ driver .switch_to .window (driver .window_handles [- 1 ])
386386 else :
387387 driver .default_get (url ) # The original one
388388 else :
@@ -392,23 +392,21 @@ def uc_special_open_if_cf(
392392
393393def uc_open (driver , url ):
394394 if (url .startswith ("http:" ) or url .startswith ("https:" )):
395+ time .sleep (0.05 )
395396 with driver :
396- time .sleep (0.18 )
397397 driver .default_get (url )
398- time .sleep (0.02 )
399398 else :
400399 driver .default_get (url ) # The original one
401400 return None
402401
403402
404403def uc_open_with_tab (driver , url ):
405404 if (url .startswith ("http:" ) or url .startswith ("https:" )):
405+ time .sleep (0.05 )
406406 with driver :
407- time .sleep (0.18 )
408407 driver .execute_script ('window.open("%s","_blank");' % url )
409408 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 ])
412410 else :
413411 driver .default_get (url ) # The original one
414412 return None
@@ -2822,25 +2820,29 @@ def get_local_driver(
28222820 )
28232821 if headless2 :
28242822 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+ ):
28262827 chrome_options .add_argument ("--headless=new" )
28272828 else :
28282829 chrome_options .add_argument ("--headless=chrome" )
28292830 except Exception :
28302831 chrome_options .add_argument ("--headless=new" )
28312832 elif headless and undetectable :
28322833 try :
2833- if int (use_version ) >= 109 :
2834+ int_use_version = int (str (use_version ).split ("." )[0 ])
2835+ if int_use_version >= 109 :
28342836 chrome_options .add_argument ("--headless=new" )
28352837 elif (
2836- int ( use_version ) >= 96
2837- and int ( use_version ) <= 108
2838+ int_use_version >= 96
2839+ and int_use_version <= 108
28382840 ):
28392841 chrome_options .add_argument ("--headless=chrome" )
28402842 else :
28412843 pass # Will need Xvfb on Linux
28422844 except Exception :
2843- pass
2845+ pass # Will need Xvfb on Linux
28442846 elif headless :
28452847 if "--headless" not in chrome_options .arguments :
28462848 chrome_options .add_argument ("--headless" )
@@ -3117,6 +3119,13 @@ def get_local_driver(
31173119 and int (use_version ) >= 72
31183120 ):
31193121 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+ )
31203129 cdp_events = uc_cdp_events
31213130 cert = "unable to get local issuer certificate"
31223131 mac_certificate_error = False
@@ -3209,7 +3218,9 @@ def get_local_driver(
32093218 and use_version
32103219 and (
32113220 int (ch_driver_version )
3212- < int (use_version )
3221+ < int (str (
3222+ use_version ).split ("." )[0 ]
3223+ )
32133224 )
32143225 )
32153226 ):
0 commit comments