Switch to pop up window using Selenium
public String determineIfCorrectUrlOnPopUp() {clickOnEmailThisSeller();// Below Line in your code will switch to the current window by using for each loopfor (String currentWindow: driver.getWindowHandles()) driver.switchTo().window(currentWindow);{ //Now you are in Popup window and you can get the pop-up window URL here System.out.println(driver.getCurrentUrl()); driver.close(); }System.out.println(driver.getCurrentUrl()); // This will return Parent window URLreturn driver.getCurrentUrl();}