MCPcopy Create free account
hub / github.com/seleniumbase/SeleniumBase / switch_to_window

Method switch_to_window

seleniumbase/fixtures/base_case.py:4049–4061  ·  view source on GitHub ↗

Switches control of the browser to the specified window. The window can be an integer: 0 -> 1st tab, 1 -> 2nd tab, etc... Or it can be a list item from self.driver.window_handles

(self, window, timeout=None)

Source from the content-addressed store, hash-verified

4047 self.wait_for_ready_state_complete()
4048
4049 def switch_to_window(self, window, timeout=None):
4050 """Switches control of the browser to the specified window.
4051 The window can be an integer: 0 -> 1st tab, 1 -> 2nd tab, etc...
4052 Or it can be a list item from self.driver.window_handles"""
4053 self.__check_scope()
4054 if not timeout:
4055 timeout = settings.SMALL_TIMEOUT
4056 if self.timeout_multiplier and timeout == settings.SMALL_TIMEOUT:
4057 timeout = self.__get_new_timeout(timeout)
4058 if self.__is_cdp_swap_needed() and not isinstance(window, str):
4059 self.cdp.switch_to_tab(window)
4060 return
4061 page_actions.switch_to_window(self.driver, window, timeout)
4062
4063 def switch_to_default_window(self):
4064 self.switch_to_window(0)

Callers 12

clickMethod · 0.95
click_link_textMethod · 0.95
js_clickMethod · 0.95
switch_to_tabMethod · 0.95
setUpMethod · 0.95

Calls 4

__check_scopeMethod · 0.95
__get_new_timeoutMethod · 0.95
__is_cdp_swap_neededMethod · 0.95
switch_to_tabMethod · 0.45

Tested by

no test coverage detected