Skip to content

Handle Multiple Windows

NaveenS edited this page Apr 18, 2020 · 2 revisions

Tab and Window

A tab is more or less same as a window. A window can contain several tabs and all session data and cookies are shared across all tabs and open window. In Selenium both tab and window are treated in the same way.

How to automate Multiple Windows.

As like alert box, for windows also you need to switch the focus from the parent window to the another window. You can switch the focus of the parent page to another window through the following code snippet.

driver.switch_to.window(window_handle)

In the above code snippet, you need to provide the respective window handles to switch the focus to your required window. To get Window handle, following properties of drivers can be used

Property Description
driver.current_window_handle Returns Window handle of currently focused browser window
driver.window_handles Returns the handles of all windows within the current session
Clone this wiki locally