window

The command to switch the driver's context to the specified Window or Browser Tab.

Syntax

py.switch_to.window(name_or_handle: str) -> Pylenium
py.switch_to.window(index: int) -> Pylenium

Usage

correct usage
# Switch to a Window by handle
windows = py.window_handles
py.switch_to.window(name_or_handle=windows[1])
correct usage
# switch to a newly opened Browser Tab by index
py.switch_to.window(index=1)

Arguments

  • name_or_handle="" (str) - The name or window handle of the Window to switch to

  • index=0 (int) - The index position of the Window Handle

index=0 will switch to the default content

Yields

  • Pylenium - The current instance of Pylenium so you can chain commands

Last updated