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

asked Sep 6, 2014 at 6:32

1 Answer 1

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;
 }
 }
 }
answered Sep 6, 2014 at 10:14

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.