driver.navigate().to("someurl.com"); String parent = driver.getWindowHandle(); System.out.println("Parent Window ID is : "+parent); driver.findElement(By.xpath("Link_of_Terms_of_Use_opens_New_Window")).click(); System.out.println("Home Page is loaded Successfully and Terms of Use Link is clicked"); Set<String> allWindows = driver.getWindowHandles(); int count = allWindows.size(); System.out.println("Total Windows : "+count); for(String child:allWindows) { if(!parent.equalsIgnoreCase(child)) { driver.switchTo().window(child); System.out.println("Child Window Title is: "+driver.getTitle()); //perform all your tasks in the new window here driver.close(); } } driver.switchTo().window(parent); System.out.println("Parent Window Title is: "+driver.getTitle());