@@ -1430,8 +1430,12 @@ def switch_to_frame(driver, frame, timeout=settings.SMALL_TIMEOUT):
1430
1430
timeout_exception (Exception , message )
1431
1431
1432
1432
1433
- def __switch_to_window (driver , window_handle ):
1434
- if hasattr (driver , "_is_using_uc" ) and driver ._is_using_uc :
1433
+ def __switch_to_window (driver , window_handle , uc_lock = True ):
1434
+ if (
1435
+ hasattr (driver , "_is_using_uc" )
1436
+ and driver ._is_using_uc
1437
+ and uc_lock
1438
+ ):
1435
1439
gui_lock = fasteners .InterProcessLock (
1436
1440
constants .MultiBrowser .PYAUTOGUILOCK
1437
1441
)
@@ -1442,14 +1446,20 @@ def __switch_to_window(driver, window_handle):
1442
1446
return True
1443
1447
1444
1448
1445
- def switch_to_window (driver , window , timeout = settings .SMALL_TIMEOUT ):
1449
+ def switch_to_window (
1450
+ driver ,
1451
+ window ,
1452
+ timeout = settings .SMALL_TIMEOUT ,
1453
+ uc_lock = True ,
1454
+ ):
1446
1455
"""
1447
1456
Wait for a window to appear, and switch to it. This should be usable
1448
1457
as a drop-in replacement for driver.switch_to.window().
1449
1458
@Params
1450
1459
driver - the webdriver object (required)
1451
1460
window - the window index or window handle
1452
1461
timeout - the time to wait for the window in seconds
1462
+ uc_lock - if UC Mode and True, switch_to_window() uses thread-locking
1453
1463
"""
1454
1464
if window == - 1 :
1455
1465
window = len (driver .window_handles ) - 1
@@ -1465,7 +1475,7 @@ def switch_to_window(driver, window, timeout=settings.SMALL_TIMEOUT):
1465
1475
shared_utils .check_if_time_limit_exceeded ()
1466
1476
try :
1467
1477
window_handle = driver .window_handles [window ]
1468
- __switch_to_window (driver , window_handle )
1478
+ __switch_to_window (driver , window_handle , uc_lock = uc_lock )
1469
1479
return True
1470
1480
except IndexError :
1471
1481
now_ms = time .time () * 1000.0
@@ -1486,7 +1496,7 @@ def switch_to_window(driver, window, timeout=settings.SMALL_TIMEOUT):
1486
1496
for x in range (int (timeout * 10 )):
1487
1497
shared_utils .check_if_time_limit_exceeded ()
1488
1498
try :
1489
- __switch_to_window (driver , window_handle )
1499
+ __switch_to_window (driver , window_handle , uc_lock = uc_lock )
1490
1500
return True
1491
1501
except NoSuchWindowException :
1492
1502
now_ms = time .time () * 1000.0
0 commit comments