I'm facing an issue when application I'm testing is opening a second level popup (I mean, a popup that rises another popup). I'm using Selenium for Java, version 2.42.2, with IE Driver.

My code currently manages all other flows and single pop ups windows, but when a second level popup appears my webdriver object gets irresponsive and just stuck in any method that try to get invoked. When this happens, I need to manually close the popup window and then driver method continues the execution of invoked method.

Maybe it worth mentioning, if I call the second popup from the main page (not from another popup) I am able to manage it without problems, so the problem seems to be related with the number of nested windows more than a specific problem for the page.

Take a look on below code:

String url = "/example.jsp"
int counter = 0;
boolean windowDetected = false;

// Waiting until page with given url gets detected
// It tries 10 times before it continues
while (counter++ < 10 && !windowDetected) {         

  waitForSeconds(1); // Just invokes Thread.sleep method, 

  System.out.println("before getting handlers, iteration " + counter + " of 10");   
  Set<String> handlers = driver.getWindowHandles();
  System.out.println("after getting handlers, number of handlers: " + handlers.size());

  for (String handler : handlers) {

    try {
      System.out.println("Moving to " + handler);
    catch (NoSuchWindowException e) {
      System.out.println("Window not found, it probably redirected to a different window");

    if (driver.getCurrentUrl().contains(url)) {
      windowDetected = true;
      waitForPageLoading(); // It just verify current page status to be completed

I am able to position properly the driver in specific window with above code in other application pages, but when having the second level popup it just hangs on line Set handlers = driver.getWindowHandles(); that is the first method called on driver object after popup appeared. Similarly, if I had called another driver method like driver.getPageSource() the same would have happened in that method.

I am not able to change application structure (my scope is only for testing it), so doing changes in web application code is not an option for me now. I have read on different options like trying Robot class, but I think it will be difficult to implement with more complex pages and difficult to maintain.

Any idea of how can I solve this issue? Many thanks in advance.

Best regards,



1 Answer 1


Actually, the problem was related to the IEDriverServer version, it seems a fix was included around version 2.37 when a dialog window calling another dialog caused to lose communication with the driver, it just hanged there. Updating to a later version solved the issue.

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.