title: Unable to get new window handle with Selenium WebDriver in Java on IE
body: <p>When I click a button on a page (in IE browser), a new popup page opens. My attempts to get the window handle for this popup have failed. Here is my first attempt:</p>
  
  <pre><code>String baseWin = driver.getWindowHandle();
  System.out.println(baseWin);
  Set&lt;String&gt;s = driver.getWindowHandles();
  Iterator&lt;String&gt; ite = s.iterator();
  while ( ite.hasNext() ) {
      String popUpHandle = ite.next();
      if(!baseWin.equals(popUpHandle)) {
          driver.switchTo().window(popUpHandle);
          System.out.println(driver.switchTo().window(popUpHandle).getTitle());
  </code></pre>
  
  <p>This attempt prints only the base window's handle, and if the second print statement is placed outside the if() statement, but within the while() statement and after the if() statement, it simply outputs the base window's title. So the set of handles only seems to contain the base window handle.</p>
  
  <p>Here is my second attempt:</p>
  
  <pre><code>String baseWin = driver.getWindowHandle();
  System.out.println(baseWin);
  ArrayList&lt;String&gt; popUpWin = new ArrayList&lt;String&gt;(driver.getWindowHandles());
  popUpWin.remove(baseWin);
  driver.switchTo().window(popUpWin.get(0));
  System.out.println(driver.switchTo().window(popUpWin.get(0)));
  </code></pre>
  
  <p>This attempt returns an error, which says that the array popUpWin is empty, i.e. size == 0. So, the popup window's handle isn't being retrieved when I call driver.getWindowHandles() and only contains the base window's handle. Is this an IE issue? Is there a workaround? Or am I overlooking something in my code? (Note that I've neglected pauses in the code that I've included here, so I don't believe that is the issue.)</p>