webdriver.remote.switch_to

Module Contents

Classes

SwitchTo(self,driver)
class SwitchTo(driver)
__init__(driver)
active_element()

Returns the element with focus, or BODY if nothing has focus.

Usage:element = driver.switch_to.active_element
alert()

Switches focus to an alert on the page.

Usage:alert = driver.switch_to.alert
default_content()

Switch focus to the default frame.

Usage:driver.switch_to.default_content()
frame(frame_reference)

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])

parent_frame()

Switches focus to the parent context. If the current context is the top level browsing context, the context remains unchanged.

Usage:driver.switch_to.parent_frame()
window(window_name)

Switches focus to the specified window.

Args:
  • window_name: The name or window handle of the window to switch to.
Usage:

driver.switch_to.window(‘main’)

_w3c_window(window_name)