title: InternetExplorerDriver StaleElementReferenceException
body: <p>I have the following Selenium test code:</p>
  
  <pre><code>waitForElementList(driver, timeout, By.xpath(elementA);
  waitForElementList(driver, timeout, By.xpath(elementB);
  waitForElementList(driver, timeout, By.xpath(elementC);
  waitForElementList(driver, timeout, By.xpath(elementD);
  waitForElementList(driver, timeout, By.xpath(elementE);
  waitForElementList(driver, timeout, By.xpath(elementF);
  
  List&lt;WebElement&gt; elementA = driver.findElements(By.xpath(elementA));
  List&lt;WebElement&gt; elementB = driver.findElements(By.xpath(elementB));
  List&lt;WebElement&gt; elementC = driver.findElements(By.xpath(elementC));
  List&lt;WebElement&gt; elementD = driver.findElements(By.xpath(elementD));
  List&lt;WebElement&gt; elementE = driver.findElements(By.xpath(elementE));
  List&lt;WebElement&gt; elementF = driver.findElements(By.xpath(elementF));
  
  for(int i = 0; i &lt; elementA.size(); i++){
      int id = Integer.valueOf(elementA.get(i).getAttribute("class"));
      //doing things with the other elements
  }
  
  public static void waitForElementList(WebDriver driver, int timeout, final By locator){
      FluentWait&lt;WebDriver&gt; wait = new FluentWait&lt;WebDriver&gt;(driver)
         .withTimeout(timeout, TimeUnit.SECONDS)
         .pollingEvery(1, TimeUnit.SECONDS)
         .ignoring(NoSuchElementException.class)
         .ignoring(StaleElementReferenceException.class);
  
      wait.until(new Function&lt;WebDriver, List&lt;WebElement&gt;&gt;() {
          public List&lt;WebElement&gt; apply(WebDriver driver) {
              return driver.findElements(locator);
          }
      });
  }
  </code></pre>
  
  <p>If I run this piece of code in any browser than Internet Explorer it works correctly. But if I run it in Internet Explorer it sometimes crashes at the line where it wants to get the Attribute "class". There appears a StaleElementReferenceException. The funny thing is this exception only appears on Windows 7 IE9 but not Windows XP IE8.
  I googled a lot how to get around this but no solution helped me. This exception appears if an element has refreshed or something but between the waitForElementList()-methods an the getAttribute call is no refresh. If I only run the first waitForElementList()-method (for elementA) and not the other waitForElementList()-methods it works. I don't know what to do now. Thanks for your help.</p>