title: selenium.common.exceptions.StaleElementReferenceException during page refresh
body: <p>Page contains some data (table with few rows). There is 'refresh' button which reload and redraw some elements on page without reloading static data (ajax).</p>
  
  <p>I'm trying to create proper test for that page, but getting StaleElementReferenceException sometimes.</p>
  
  <p>My code (python):</p>
  
  <pre><code>from selenium import webdriver
  browser=webdriver.Firefox()
  browser.get('http://mytisite')
  browser.implicitly_wait(10)
  browser.find_element_by_id('start').click()
  while browser.find_element_by_id('status').text!='Done':
      browser.find_element_by_id('refresh').click()
      for row in browser.find_elements_by_class_name('datarow'):
          if not is_correct(row.text):
             print "incorrect"
      time.sleep(10)
  </code></pre>
  
  <p>1 of 5 iterations fails on line "if not is_correct(row.text)": </p>
  
  <pre><code>selenium.common.exceptions.StaleElementReferenceException: 
   Message: u'Element not found in the cache - perhaps the page 
   has changed since it was looked up' ; Stacktrace: Method 
   fxdriver.cache.getElementAt threw an error in 
   resource://fxdriver/modules/web_element_cache.js 
  </code></pre>
  
  <p>Main problem: page already contains previous data, so I'm getting race between ajax refresh and webdriver's element query of <code>find_elements_by_class_name('datarow')</code>.</p>
  
  <p>How can I proper solve race between ajax refresh and webdriver? Thanks.</p>