@@ -1430,8 +1430,12 @@ def switch_to_frame(driver, frame, timeout=settings.SMALL_TIMEOUT):
14301430 timeout_exception (Exception , message )
14311431
14321432
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+ ):
14351439 gui_lock = fasteners .InterProcessLock (
14361440 constants .MultiBrowser .PYAUTOGUILOCK
14371441 )
@@ -1442,14 +1446,20 @@ def __switch_to_window(driver, window_handle):
14421446 return True
14431447
14441448
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+ ):
14461455 """
14471456 Wait for a window to appear, and switch to it. This should be usable
14481457 as a drop-in replacement for driver.switch_to.window().
14491458 @Params
14501459 driver - the webdriver object (required)
14511460 window - the window index or window handle
14521461 timeout - the time to wait for the window in seconds
1462+ uc_lock - if UC Mode and True, switch_to_window() uses thread-locking
14531463 """
14541464 if window == - 1 :
14551465 window = len (driver .window_handles ) - 1
@@ -1465,7 +1475,7 @@ def switch_to_window(driver, window, timeout=settings.SMALL_TIMEOUT):
14651475 shared_utils .check_if_time_limit_exceeded ()
14661476 try :
14671477 window_handle = driver .window_handles [window ]
1468- __switch_to_window (driver , window_handle )
1478+ __switch_to_window (driver , window_handle , uc_lock = uc_lock )
14691479 return True
14701480 except IndexError :
14711481 now_ms = time .time () * 1000.0
@@ -1486,7 +1496,7 @@ def switch_to_window(driver, window, timeout=settings.SMALL_TIMEOUT):
14861496 for x in range (int (timeout * 10 )):
14871497 shared_utils .check_if_time_limit_exceeded ()
14881498 try :
1489- __switch_to_window (driver , window_handle )
1499+ __switch_to_window (driver , window_handle , uc_lock = uc_lock )
14901500 return True
14911501 except NoSuchWindowException :
14921502 now_ms = time .time () * 1000.0
0 commit comments