After the login there is a pop-up window that needs to be closed. Inspect element (IE 11, GC) does not work for this pop-up window. Questions: - How to focus to this pop-up window (java) - How to identify the X button in pop-up window to close it using Java? Thank you!
You need to switch to the pop-up window and then close it
String parentWindowHandler = driver.getWindowHandle(); // Store your parent window
String subWindowHandler = null;
Set<String> handles = driver.getWindowHandles(); // get all window handles
Iterator<String> iterator = handles.iterator();
while (iterator.hasNext()){
subWindowHandler = iterator.next();
}
driver.switchTo().window(subWindowHandler); // switch to popup window
// Now you are in the popup window, perform necessary actions here
driver.close();
driver.switchTo().window(parentWindowHandler); // switch back to parent window
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.