Skip to content

Commit cc0749b

Browse files
committed
Add "tab" methods that work the same as "window" methods
1 parent 9a42cf0 commit cc0749b

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

help_docs/method_summary.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,12 +202,16 @@ self.set_content_to_frame(frame, timeout=None)
202202
self.set_content_to_default(nested=True)
203203

204204
self.open_new_window(switch_to=True)
205+
# Duplicates: self.open_new_tab(switch_to=True)
205206

206207
self.switch_to_window(window, timeout=None)
208+
# Duplicates: self.switch_to_tab(tab, timeout=None)
207209

208210
self.switch_to_default_window()
211+
# Duplicates: self.switch_to_default_tab()
209212

210213
self.switch_to_newest_window()
214+
# Duplicates: self.switch_to_newest_tab()
211215

212216
self.get_new_driver(
213217
browser=None, headless=None, locale_code=None, protocol=None,

seleniumbase/fixtures/base_case.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6027,6 +6027,25 @@ def reload_page(self):
60276027
""" Same as self.refresh_page() """
60286028
self.refresh_page()
60296029

6030+
def open_new_tab(self, switch_to=True):
6031+
""" Same as self.open_new_window() """
6032+
self.open_new_window(switch_to=switch_to)
6033+
6034+
def switch_to_tab(self, tab, timeout=None):
6035+
""" Same as self.switch_to_window()
6036+
Switches control of the browser to the specified window.
6037+
The window can be an integer: 0 -> 1st tab, 1 -> 2nd tab, etc...
6038+
Or it can be a list item from self.driver.window_handles """
6039+
self.switch_to_window(window=tab, timeout=timeout)
6040+
6041+
def switch_to_default_tab(self):
6042+
""" Same as self.switch_to_default_window() """
6043+
self.switch_to_default_window()
6044+
6045+
def switch_to_newest_tab(self):
6046+
""" Same as self.switch_to_newest_window() """
6047+
self.switch_to_newest_window()
6048+
60306049
def input(
60316050
self, selector, text, by=By.CSS_SELECTOR, timeout=None, retry=False
60326051
):

0 commit comments

Comments
 (0)