I want to scroll down the website by looping through all webElements and I'm doing it in this way:
driver.get('https://justjoin.it/')
driver.maximize_window()
while True:
for web_element in driver.find_elements_by_class_name('css-1x9zltl'):
driver.execute_script("arguments[0].scrollIntoView();", web_element)
Unfortunately after few seconds scroll bar stops and console throws me this exception:
Message: stale element reference: element is not attached to the page document
Looking for solutions I searched a lot of webpages and now I know why I have this type of error. I tried to solve that by using try/except and it works but of course it doesn't solve the essence of the problem. I want to know Is there a better way to solve my issue?