title: Selenium - stale element reference: element is not attached to the page
body: <p>I am trying to understand why it gives an error while I am trying to display items that took from websites.
  I am also using google chrome for a browser.</p>
  
  <pre><code>chromeDriver.Navigate().GoToUrl("somewebsites");
  
  chromeDriver.FindElement(By.Id("something.link.text")).Click();
  chromeDriver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5));
  </code></pre>
  
  <p>And this other parts of my code</p>
  
  <pre><code>var item = chromeDriver.FindElementsByXPath("//*[starts-with(@id,\"g_1_\")]/td[3]/span");
  foreach (var value in item)
  {
      Console.WriteLine(value.Text); 
  }
  </code></pre>
  
  <p>Whenever I use "<strong>chromeDriver.FindElement(By.Id("something.link.text")).Click();"</strong>, it gives an error. I can't display the data that I pulled. </p>
  
  <p>In the error message, It says "<strong>OpenQA.Selenium.StaleElementReferenceException: 'stale element reference: element is not attached to the page document</strong>". I checked the other posts, but I did not figure it out. How can I solve it? </p>
  
  <p>As I read, selenium gives much faster response than website opening time, so it gives the error. Also, rarely, it gives that selenium cannot be located the element. Any suggestion?</p>
  
  <p>EDIT: If I remove "<strong>.text</strong>" from display function, It displays "<strong>OpenQA.Selenium.Remote.RemoteWebElement</strong>". Does the problems with strings ?</p>
  
  <p>EDIT2:  I can hold data that I took from websites as like this:</p>
  
  <p><strong>[i]="System.Collections.ObjectModel.ReadOnlyCollection`1[OpenQA.Selenium.IWebElement]"</strong>
  For this, I wrote something like this:</p>
  
  <pre><code>string[] test= new string[100];
  
  for (int i = 0; i &lt; 100; i++)
  {
       kaan[i] = driver.FindElements(By.XPath("//*[starts-with(@id,\"g_1_\")]/td[3]/span")).ToString();
  }
  </code></pre>
  
  <p>How can I convert to the text </p>