December 8, 2014

Working with Multiple windows using selenium webdriver

December 08, 2014 0
Working with Multiple windows using selenium webdriver
In this blog post i am trying to address easiest way to handle multiple windows.

Selenium webdriver has mechanism to identify windows.

getWindowHandle() ---
Return an opaque handle to this window that uniquely identifies it within this driver instance. This can be used to switch to this window at a later date.

Return a set of window handles which can be used to iterate over all open windows of this WebDriver instance by passing them to switchTo().WebDriver.Options.window()

In this example script will perform some actions on main window, after clicking a link it will open a new window and webdriver will switch to child window and perform actions. Once the actions are done on child window it will close child window and switch back to parent window.

Here is the code..