Skip to content

Commit cf0746b

Browse files
committed
Cover a special edge case with previous Safari versions
1 parent a455c48 commit cf0746b

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

seleniumbase/fixtures/page_actions.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1296,6 +1296,16 @@ def switch_to_window(driver, window, timeout=settings.SMALL_TIMEOUT):
12961296
start_ms = time.time() * 1000.0
12971297
stop_ms = start_ms + (timeout * 1000.0)
12981298
if isinstance(window, int):
1299+
caps = driver.capabilities
1300+
if (
1301+
caps["browserName"].lower() == "safari"
1302+
and "safari:platformVersion" in caps
1303+
and caps["safari:platformVersion"].split(".") < ["10", "15"]
1304+
):
1305+
# Fix reversed window_handles on Safari 10.14 or lower
1306+
window = len(driver.window_handles) - 1 - window
1307+
if window < 0:
1308+
window = 0
12991309
for x in range(int(timeout * 10)):
13001310
shared_utils.check_if_time_limit_exceeded()
13011311
try:

0 commit comments

Comments
 (0)