Selenium WebDriver – How To Automatically Switch Among Browser Windows

Overview: One of the common challenges we face while automating our tests is – switching between open windows. Many of us would have seen the code as shown below. // get the current window handle String parentHandle = driver.getWindowHandle(); for (String handle: driver.getWindowHandles()) { if (!parentHandle.equals(handle)) driver.switchTo().window(handle); } There is nothing wrong in the above code […]