title: getting attribute gives error after one loop in selenium
body: <p>i want to get source from a job listing site but when i click on a job link and get description than come back <strong>get_attribute()</strong> method gets broken.i am new to this stuff so i need some help on this.</p>
  <p>my code:</p>
  <pre><code>all_jobs = driver.find_elements_by_class_name(&quot;index-middle&quot;)
  
  for job in all_jobs:
  
   result_html = job.get_attribute(&quot;innerHTML&quot;)
   soup = BeautifulSoup(result_html, &quot;html.parser&quot;)
  
    showmore=WebDriverWait(driver, 15).until(EC.presence_of_element_located((By.CLASS_NAME,'job')))
              
    showmore.click()
   
   
   try:
       description = soup.find(&quot;a&quot;,class_=&quot;desc&quot;).text
   except:
       description = &quot;None&quot;
  
   driver.execute_script(&quot;window.history.go(-1)&quot;)
  
  
  </code></pre>
  <p>i want to repeat this action in for loop but when it gets a one job description it gives error.</p>
  <p>error:</p>
  <pre><code>  Traceback (most recent call last):
      File &quot;joblist.py&quot;, line 46, in &lt;module&gt;
      result_html = job.get_attribute(&quot;innerHTML&quot;)
  selenium.common.exceptions.StaleElementReferenceException: Message: stale element
  reference: element is not attached to the page document
  </code></pre>
  <p>what should i do ?</p>