I am trying to build a scraper using selenium package for python but I am getting this error:
Message: stale element reference: element is not attached to the page document
(Session info: headless chrome=83.0.4103.61)
I am using google colab. My code is:
import selenium
driver = webdriver.Chrome('chromedriver',chrome_options=chrome_options)
titles=[]
for link in links:
driver.get(link)
data = driver.find_elements_by_xpath('.//a[@class = "question-hyperlink"]')
titles.append(data[0].text)
The error is in line data = driver.find_elements_by_xpath('.//a[@class = "question-hyperlink"]')
I was told to try exception handling but I am unable to implement it. Please help me with how can I implement it.