title: Selenium Chromedriver and IEdriver No Such Window exception
body: <p>I am having this issue in selenium where the original window is getting closed instead of a new window that is open and targeted. The code runs smoothly on firefox. But in Chrome (really fast) and IE it fails with an exception: org.openqa.selenium.NoSuchWindowException: no such window. </p>
  
  <p>I think it has something to do with the speed of the test? So, chrome tries super fast when closing the window? How do you actually close the new window and switch back to the original one and interact with it? </p>
  
  <p>Here is the snippet of my code. </p>
  
  <pre><code> try {
          Thread.sleep(5000);
      } catch (InterruptedException e) {
          e.printStackTrace();
      } 
  String originalWindow = driver.getWindowHandle();
  String newWindow;
  Set&lt;String&gt; windowHandles = driver.getWindowHandles();
  Iterator&lt;String&gt; stringIterator = windowHandles.iterator();
  
  while (stringIterator.hasNext()) {
      newWindow = stringIterator.next();
      if (!originalWindow.equalsIgnoreCase(newWindow)) {
          driver.switchTo().window(newWindow);
          System.out.println("The title of the page is: “ + driverInstance.getTitle());
        }
  
  }
  driver.close(); ///In here I should close the new window 
  
  driver.switchTo().window(originalWindow); ///In here I should switch back to the old window
  </code></pre>