I have a written a Geb script for automation and I need to handle the Popup. but when switching the child window to parent window am getting a No Such Window Exception
Below is my code:
def AcceptSecurity(){
log.info("Click Next")
String parentWindowHandler = browser.getAvailableWindows() // Store your parent window
String subWindowHandler = null
Set<String> handles = browser.getAvailableWindows() // get all window handles
Iterator<String> iterator = handles.iterator()
while (iterator.hasNext()){
subWindowHandler = iterator.next()
}
browser.switchToWindow(subWindowHandler) // switch to popup window
SecurityNext.click()
log.info("Get the Parent Window")
browser.switchToWindow(parentWindowHandler) // switch back to parent window
}