title: " Exception in thread "main" java.util.NoSuchElementException " error is occured when i execute the following code.
body: <p>I wrote a code in webdriver for getting the window id of tab window but code throws a exception . 
      " Exception in thread "main" java.util.NoSuchElementException "  error is occured when i execute the following code.  </p>
  
  <pre><code>import java.util.Iterator;
  import java.util.Set;
  
  import org.openqa.selenium.By;
  import org.openqa.selenium.WebDriver;
  import org.openqa.selenium.firefox.FirefoxDriver;
  public class web_windows {
  
      public static void main(String[] args) {
  
          WebDriver driver = new FirefoxDriver();
          driver.get("http://www.icicibank.com/");
          Set&lt;String&gt; winids = driver.getWindowHandles();
          Iterator&lt;String&gt; iterate = winids.iterator();
  
          System.out.println(iterate.next());
  
          driver.findElement(By.xpath("//*[@id='footer_container']/p/a[1]")).click();
          winids = driver.getWindowHandles();
          iterate = winids.iterator();
          String firstwindow = iterate.next(); // window id of main window
  
          String tabwindow = iterate.next();  // window id of tabbed window
          // main tab 
          System.out.println(firstwindow);
          // tabbed window
          System.out.println(tabwindow);
  
  
  
  
  
      }
  
  }
  </code></pre>
  
  <p>After execting above code following error is coming: </p>
  
  <pre><code>Exception in thread "main" java.util.NoSuchElementException
      at java.util.LinkedHashMap$LinkedHashIterator.nextEntry(Unknown Source)
      at java.util.LinkedHashMap$KeyIterator.next(Unknown Source)
      at web_windows.main(web_windows.java:
  </code></pre>