Deepak Sabastein
Deepak Sabastein

Reputation: 197

handling multiple windows in selenium webdriver and what is WindowName

How we can find the "WindowName" for specifying it in driver.switchTo().window(windowName); method.. I couldn't find the window's name anywhere.

Upvotes: 1

Views: 2751

Answers (1)

Alpha
Alpha

Reputation: 14076

Apart from window name, windows can also be identified by window handles. Hence your syntax for switching to window will be:

driver.switchTo().window(windowHandle);

you can get window handles of all windows by following and can switch to window you want by selecting respective window handle:

Set<String> allWindows = driver.getWindowHandles();

If your html code something like following:

<button id="helpbutton" onClick='window.open("help.html","HelpWindow","width=500,height=500");'>Help</button>

in this case, "HelpWindow" is window name.

Upvotes: 1

Related Questions