WebDriver driver = new FirefoxDriver();
driver.get("https://www.flipkart.com");
driver.manage().window().maximize();
String parentWindowHandler = driver.getWindowHandle(); // Saving the parent window
String subWindowHandler = null;
Set<String> handles = driver.getWindowHandles(); // Getting all window handles
Iterator<String> iterator = handles.iterator();
while (iterator.hasNext()){
subWindowHandler = iterator.next();
}
driver.switchTo().window(subWindowHandler);
I attempted to switch back to the main window as well. Could anyone provide helpful suggestions or code for closing the pop-up?