简体   繁体   中英

How to handle nested popup windows in selenium webdriver with java?

Attached_image

Please help, i am trying to automate a project(using java) where i need to operate on nested popup windows ie with a main window i have a popup which includes one more window inside it. You can check the image I have attached . The problem what i am facing is,

org.openqa.selenium.NoSuchElementException: Unable to find element with id == btnSign (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 10.22 seconds

ie it is not able to find the element that is inside 2nd scroll. Note. (I am working on IE) Can anyone give an idea how to handle it. Thanks in advance.

You can switch any number of windows using below code.

String parentWindow = webDriver.getWindowHandle();
Set<String> handles = webDriver.getWindowHandles();
        for (String windowHandle : handles) {
            if (!windowHandle.equals(parentWindow)) {
                webDriver.switchTo().window(windowHandle);
            }
        }

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM