Skip to content

Commit 1c526f1

Browse files
authored
Merge pull request #2890 from seleniumbase/fix-windows-bug-in-uc-mode
Fix Windows thread-locking bug in UC Mode
2 parents 3dbaf41 + 74cb173 commit 1c526f1

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

seleniumbase/__version__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# seleniumbase package
2-
__version__ = "4.28.2"
2+
__version__ = "4.28.3"

seleniumbase/core/browser_launcher.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@ def uc_gui_handle_cf(driver, frame="iframe"):
672672
if not is_in_frame:
673673
# Make sure the window is on top
674674
page_actions.switch_to_window(
675-
driver, driver.current_window_handle, 2
675+
driver, driver.current_window_handle, 2, uc_lock=False
676676
)
677677
if not is_in_frame or needs_switch:
678678
# Currently not in frame (or nested frame outside CF one)

seleniumbase/fixtures/page_actions.py

+15-5
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)