We will be using the website http://popuptest.com/goodpopups.html to demonstrate non-modal pop-up windows. We will write a small program to load this URL and then click the Good PopUp #1 link. A pop-up window will open and then we will fetch the window handles of both the open windows.
The following code clicks a link on the home page and fetches the window handles of both the open windows as well as their titles:
WebDriver driver = new ChromeDriver();
driver.manage().window().maximize();
driver.navigate().to("http://popuptest.com/goodpopups.html");
driver.findElement(By.xpath("//a[text()='Good PopUp #1']")).click();
Set openWindows = driver.getWindowHandles();
System.out.println("No of open windows: " + openWindows.size());
Iterator<String> it = openWindows.iterator();
String parent = it.next();
System...