selenium.webdriver.remote.switch_to¶
Classes
|
- class selenium.webdriver.remote.switch_to.SwitchTo(driver)[source]¶
- property active_element: WebElement¶
Returns the element with focus, or BODY if nothing has focus.
- Usage:
element = driver.switch_to.active_element
- property alert: Alert¶
Switches focus to an alert on the page.
- Usage:
alert = driver.switch_to.alert
- default_content() None [source]¶
Switch focus to the default frame.
- Usage:
driver.switch_to.default_content()
- frame(frame_reference: str | int | WebElement) None [source]¶
Switches focus to the specified frame, by index, name, or webelement.
- Args:
- frame_reference: The name of the window to switch to, an integer representing the index,
or a webelement that is an (i)frame to switch to.
- Usage:
driver.switch_to.frame('frame_name') driver.switch_to.frame(1) driver.switch_to.frame(driver.find_elements(By.TAG_NAME, "iframe")[0])
- new_window(type_hint: str | None = None) None [source]¶
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.
- Usage:
driver.switch_to.new_window('tab')