2

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

driver.findElement(By.xpath("//body[@id='ext-gen1018']/div[@id='contentPanel-1461']/div[@id='contentPanel-1461-body']/div[@id='campaigns-1464']/div[@id='campaigns-1464-body']/span[@id='campaigns-1464-outerCt']/div[@id='campaigns-1464-innerCt']/div[@id='campaignscoveragegrid-1494']/div[@id='toolbar-1507']/div[@id='toolbar-1507-innerCt']/div[@id='toolbar-1507-targetEl']/a[@id='button-1508']/span[@id='button-1508-btnWrap']/span[@id='button-1508-btnEl']/span[@id='button-1508-btnIconEl']")).click();

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

I am getting no such element exception

3

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) {
                driver.switchTo().window(window);
                if (driver.getTitle().contains(windowTitle)) {
                    return;
                }
            }
        }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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