ExecuteAutomation

Handing Popup window in Selenium

In this post we will discuss handing and working in popup window using Selenium WebDriver. There are situations, where we might need to work with a popup windows like entering data within a text control, selecting a dropdown control etc, but by default, selenium Webdriver does not know if there is a popup window, until you specify to it explicitly. Hence, to specify explicitly about the popup window, first we need to get the handle of window opened using getWindowHandle() method of WebDriver. Using this handle, we can pass it as a parameter for the SwitchTo().Window() method of WebDriver to start working in popup window. Here is the complete video of the above discussion. Here is the complete code for the above discussion
public static void SwitchWindow(WebDriver driver) {
	for (String windowName : driver.getWindowHandles()) {
	      driver.switchTo().window(windowName);
	}
}
Thanks for watching the video and reading the post !!! Please leave your comments and let me know if there is anything need to improved in this post. Thanks, Karthik KK