I am working on a application that opens a form to fill up when i click on a button. I need to switch to that window , fill up the form and come out I tried this code

Set beforePopup = driver.getWindowHandles();

//code to click on add button to open the pop-up


    Set <String> wndHandler = driver.getWindowHandles();
    Iterator <String> it = wndHandler.iterator();
    String Parent = it.next();
    String Child = it.next();

I am getting no such element exception

1 Answer 1


you can use following code to switch between windows based on the window title. or please go through this link Link

 private void handleMultipleWindows(String windowTitle) {
            Set<String> windows = driver.getWindowHandles();

            for (String window : windows) {
                if (driver.getTitle().contains(windowTitle)) {

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.