title: stale element reference: element is not attached to the page document
body: <p>I have list which has multiple links under each section. Each section has same links I need to click a particular link under each section. I have written the below code but when it executes it gives me <code>stale element reference: element is not attached to the page document</code> error.</p>
  
  <p>This is my code:</p>
  
  <pre><code>public static void main(String[] args) throws InterruptedException 
  {
      WebDriver driver = new ChromeDriver();
      driver.navigate().to("url......");
          driver.findElement(By.id("Login1_txtEmailID")).sendKeys("hourbank5@....com");
      driver.findElement(By.id("Login1_txtPassword")).sendKeys("Testing1*");
      driver.findElement(By.id("Login1_btnLogin")).click();
      List&lt;WebElement&gt; LeftNavLinks=driver.findElements(By.xpath("//*[@id='sliding-navigation']//a"));
      Thread.sleep(1000);
      String ben="Benefit Status";
      String[] linkTexts = new String[LeftNavLinks.size()];
      int i = 0;
      for (WebElement e : LeftNavLinks) 
      {   
          linkTexts[i] = e.getText();
          System.out.print(i+" " + linkTexts[i]+"\n");
          if(linkTexts[i].equals(ben))
          {
              String BenefitStatLi="//*[@id='sliding-navigation']/li[%s]/a";
              System.out.print(i+" " + linkTexts[i]+"\n");
                  driver.findElement(By.xpath(String.format(BenefitStatLi,i))).click();
              driver.findElement(By.xpath("//* [@id='divContentHolder']/div[1]/a[1]")).click();
          }
          i++;
      }
  }
  
  }
  </code></pre>
  
  <p>This is the HTML structure is as below</p>
  
  <pre><code>&lt;div id="ucAdminMenu_divMenu"&gt;
    &lt;ul id="sliding-navigation"&gt;
      &lt;li class="sliding-element"&gt;
        &lt;a href=" "&gt;Claims Status&lt;/a&gt;
      &lt;/li&gt;
      &lt;li class="sliding-element"&gt;
        &lt;a href=" "&gt;Eligibility Status&lt;/a&gt;
      &lt;/li&gt;
      &lt;li class="sliding-element"&gt;
        &lt;h3&gt;Section-1&lt;/h3&gt;
      &lt;/li&gt;
      &lt;li class="sliding-element"&gt;
        &lt;a href=" "&gt;Forms and Documents&lt;/a&gt;
      &lt;/li&gt;
      &lt;li class="sliding-element"&gt;
        &lt;a href=" HourBank.aspx?id=002"&gt;Hour Bank&lt;/a&gt;
      &lt;/li&gt;
      &lt;li class="sliding-element"&gt;
        &lt;h3&gt;Section-2&lt;/h3&gt;
      &lt;/li&gt;
      &lt;li class="sliding-element"&gt;
        &lt;a href=" "&gt;Benefit Status&lt;/a&gt;
      &lt;/li&gt;
      &lt;li class="sliding-element"&gt;
        &lt;a href=" "&gt;Forms and Documents&lt;/a&gt;
      &lt;/li&gt;
      &lt;li class="sliding-element"&gt;
        &lt;h3&gt;Section-3&lt;/h3&gt;
      &lt;/li&gt;
      &lt;li class="sliding-element"&gt;
        &lt;a href=" "&gt;Forms and Documents&lt;/a&gt;
      &lt;/li&gt;
      &lt;li class="sliding-element"&gt;
        &lt;h3&gt;Testing Fund&lt;/h3&gt;
      &lt;/li&gt;
      &lt;li class="sliding-element"&gt;
        &lt;a href=" "&gt;Benefit Status&lt;/a&gt;
      &lt;/li&gt;
      &lt;li class="sliding-element"&gt;
        &lt;a href=" "&gt;Order ID Card&lt;/a&gt;
      &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>The Error Trace is: </p>
  
  <pre><code>    Exception in thread "main" 
  org.openqa.selenium.StaleElementReferenceException: stale element 
  reference: element is not attached to the page document
  </code></pre>