MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / new_window

Method new_window

py/selenium/webdriver/remote/switch_to.py:91–101  ·  view source on GitHub ↗

Switches to a new top-level browsing context. The type hint can be one of "tab" or "window". If not specified the browser will automatically select it. Example: driver.switch_to.new_window("tab")

(self, type_hint: str | None = None)

Source from the content-addressed store, hash-verified

89 self._driver.execute(Command.SWITCH_TO_FRAME, {"id": frame_reference})
90
91 def new_window(self, type_hint: str | None = None) -> None:
92 """Switches to a new top-level browsing context.
93
94 The type hint can be one of "tab" or "window". If not specified the
95 browser will automatically select it.
96
97 Example:
98 driver.switch_to.new_window("tab")
99 """
100 value = self._driver.execute(Command.NEW_WINDOW, {"type": type_hint})["value"]
101 self._w3c_window(value["handle"])
102
103 def parent_frame(self) -> None:
104 """Switch focus to the parent browsing context.

Calls 2

_w3c_windowMethod · 0.95
executeMethod · 0.65