I'm running a table that has some links that I need to access, grab the contents of this link, go back and keep scrolling. These links do not have the "href" attribute, you need to click on them to work. But when I click on them to go back and keep going, this error occurs: "stale element reference: element is not attached to the document page"
This is my code that does this:
tb = driver.find_elements_by_tag_name('table')[1] tbody = tb.find_elements_by_tag_name('tbody')[0]
for row in tbody.find_elements_by_xpath('./tr'): cols = row.find_elements_by_xpath('./td')
link = cols[0].find_elements_by_tag_name('a')[0]
link.click()
time.sleep(4)
lines_extract = driver.find_elements_by_tag_name('tbody')[0].find_elements_by_xpath('./tr')
for le in lines_extract:
td_num_doc = le.find_elements_by_xpath('./td')[0]
print(td_num_doc)
div_link_back = driver.find_elements_by_tag_name('div')[2]
div_link_back.find_elements_by_tag_name('a')[0].click()