@@ -184,6 +184,7 @@ def extend_driver(driver):
184
184
driver .get_origin = DM .get_origin
185
185
driver .get_user_agent = DM .get_user_agent
186
186
driver .highlight = DM .highlight
187
+ driver .highlight_click = DM .highlight_click
187
188
driver .sleep = time .sleep
188
189
driver .get_page_source = DM .get_page_source
189
190
driver .get_title = DM .get_title
@@ -412,12 +413,14 @@ def uc_open_with_tab(driver, url):
412
413
return None
413
414
414
415
415
- def uc_open_with_reconnect (driver , url ):
416
- """Open a url, then reconnect with UC before switching to the window."""
416
+ def uc_open_with_reconnect (driver , url , reconnect_time = None ):
417
+ """Open a url, disconnect chromedriver, wait, and reconnect."""
418
+ if not reconnect_time :
419
+ reconnect_time = constants .UC .RECONNECT_TIME
417
420
if (url .startswith ("http:" ) or url .startswith ("https:" )):
418
421
driver .execute_script ('window.open("%s","_blank");' % url )
419
- driver .reconnect (2.65 )
420
422
driver .close ()
423
+ driver .reconnect (reconnect_time )
421
424
driver .switch_to .window (driver .window_handles [- 1 ])
422
425
else :
423
426
driver .default_get (url ) # The original one
@@ -1314,9 +1317,9 @@ def get_driver(
1314
1317
binary_location = None
1315
1318
if (uc_cdp_events or uc_subprocess ) and not undetectable :
1316
1319
undetectable = True
1317
- if is_using_uc ( undetectable , browser_name ) and mobile_emulator :
1318
- if not user_agent :
1319
- user_agent = constants .Mobile .AGENT
1320
+ if mobile_emulator and not user_agent :
1321
+ # Use a Pixel user agent by default if not specified
1322
+ user_agent = constants .Mobile .AGENT
1320
1323
if page_load_strategy and page_load_strategy .lower () == "none" :
1321
1324
settings .PAGE_LOAD_STRATEGY = "none"
1322
1325
proxy_auth = False
@@ -3478,7 +3481,9 @@ def get_local_driver(
3478
3481
lambda url : uc_open_with_tab (driver , url )
3479
3482
)
3480
3483
driver .uc_open_with_reconnect = (
3481
- lambda url : uc_open_with_reconnect (driver , url )
3484
+ lambda * args , ** kwargs : uc_open_with_reconnect (
3485
+ driver , * args , ** kwargs
3486
+ )
3482
3487
)
3483
3488
if mobile_emulator :
3484
3489
uc_metrics = {}
0 commit comments