Element is not attached to the page document - Selenium python
Есть код:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
def main():
final_titles, final_hrefs, final_prices = [], [], []
deep = 5
chrome_options = Options()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--no-sandbox')
driver = webdriver.Chrome(chrome_options=chrome_options)
for i in range(deep+1):
driver.get('https://www.olx.ua/elektronika/kompyutery-i-komplektuyuschie/?page='+str(i))
titles = driver.find_elements_by_class_name('lheight22')
hrefs = driver.find_elements_by_class_name('marginright5')
prices = driver.find_elements_by_class_name('price')
final_titles += titles
final_hrefs += hrefs
final_prices += prices
for title, href, price in zip(final_titles, final_hrefs, final_prices):
print(f"{title.text} | {price.text} | {href.get_attribute('href')}")
if __name__ == '__main__':
main()
Выдает ошибку:
StaleElementReferenceException Message: stale element reference: element is not attached to the page document
Не могу понять: в чем дело? Буду очень признателен за помощь