Use the newer way of opening a new tab / window

This commit is contained in:
Michael Mintz 2022-09-08 22:27:29 -04:00
parent cf0746b39c
commit c0f10820b1
1 changed files with 7 additions and 2 deletions

View File

@ -3103,9 +3103,14 @@ class BaseCase(unittest.TestCase):
def open_new_window(self, switch_to=True):
"""Opens a new browser tab/window and switches to it by default."""
self.wait_for_ready_state_complete()
self.driver.execute_script("window.open('');")
if selenium4_or_newer and switch_to:
self.driver.switch_to.new_window("tab")
else:
self.driver.execute_script("window.open('');")
time.sleep(0.01)
if switch_to:
if self.browser == "safari":
self.wait_for_ready_state_complete()
if switch_to and not selenium4_or_newer:
self.switch_to_newest_window()
time.sleep(0.01)
if self.browser == "safari":