title: Selenium - Stale element reference: element is not attached to the page document in C#
body: <p>I was using selenium to get data in a table of the website to analytics. I'm must scan and get a table approximately ~1000 rows.</p>
  
  <p>I know the page has Javascript, which automatically updates the DOM. But the table too many rows, so when I scan my code always throw an exception.</p>
  
  <p>I tried with this code:</p>
  
  <pre><code>Boolean breakIt = true;
  List&lt;IWebElement&gt; result = new List&lt;IWebElement&gt;();
  while (true)
  {
      breakIt = true;
      try
      { 
            IWebElement baseTable = browser.FindElementById("column2");
            ReadOnlyCollection&lt;IWebElement&gt; rowsTable = baseTable.FindElements(By.XPath("id('oTable')/table/tbody/tr"));
            foreach (IWebElement rows in rowsTable) {
                  if (rows.FindElements(By.XPath("td")).Count == 10)
                       result.Add(rows);
            }
            if (breakIt)
            {
                   break;
            }
       }
       catch (StaleElementReferenceException ser)
       {
            if (ser.Message.Contains("element is not attached"))
            {
                   browser.Refresh();
                   browser.WaitForPageToLoad();
                   browser.GoToFrame(browser.FindElementByXPath("//*[@id='form1']/div[3]/iframe"));
                   breakIt = false;
            }
       }
  }
  </code></pre>
  
  <p>It throws an exception like:</p>
  
  <blockquote>
    <p>Stale element reference: element is not attached to the page document.</p>
  </blockquote>
  
  <p>Have any idea to resolve my problem? I think using multiple <code>Thread</code> is the best method.</p>
  
  <p>But I tried with multiple <code>Thread</code> it also return exceptions.</p>
  
  <p>I think after getting <code>rowsTable.Count</code>. Divide this /2. And create two thread run this?</p>