title: StaleElementReferenceException on Python Selenium
body: <p>I am getting the following error while using Selenium in python:</p>
  
  <pre><code>selenium.common.exceptions.StaleElementReferenceException: Message: u'stale element reference: element is not attached to the page document\n
  </code></pre>
  
  <p>Interestingly enough, the error pops up at different times in the for loop.  Sometimes it gets through eg. 4 iterations and other times eg. 7.</p>
  
  <p>Some of the relevant code being run is:</p>
  
  <pre><code>for i in range(0, 22):
      u = driver.find_elements_by_id("data")
      text = u[0].get_attribute("innerHTML")
      driver.find_elements_by_class_name("aclassname")[0].click()
  </code></pre>
  
  <p>What does this error mean and what is something I can try to fix this?</p>