Skip to content

Commit c0f1082

Browse files
committed
Use the newer way of opening a new tab / window
1 parent cf0746b commit c0f1082

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

seleniumbase/fixtures/base_case.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3103,9 +3103,14 @@ def set_content_to_parent_frame(self):
31033103
def open_new_window(self, switch_to=True):
31043104
"""Opens a new browser tab/window and switches to it by default."""
31053105
self.wait_for_ready_state_complete()
3106-
self.driver.execute_script("window.open('');")
3106+
if selenium4_or_newer and switch_to:
3107+
self.driver.switch_to.new_window("tab")
3108+
else:
3109+
self.driver.execute_script("window.open('');")
31073110
time.sleep(0.01)
3108-
if switch_to:
3111+
if self.browser == "safari":
3112+
self.wait_for_ready_state_complete()
3113+
if switch_to and not selenium4_or_newer:
31093114
self.switch_to_newest_window()
31103115
time.sleep(0.01)
31113116
if self.browser == "safari":

0 commit comments

Comments
 (0)