Here's my code:
elements = driver.find_elements(By.CLASS_NAME, 'name') for i in elements: i.click() driver.back() Error: selenium.common.exceptions.StaleElementReferenceException: Message: stale element reference: stale element not found.
When I tried this...
elements = driver.find_elements(By.CLASS_NAME, 'name') for i in range(len(elements)): elements[i].click() time.sleep(2) driver.back() elements = driver.find_elements(By.CLASS_NAME, 'name') ...it shows list index out of range error.
First I stored a list of web elements (links) in a list, then I looped through the list and told selenium to click the web element (going to another page and coming back). Whenever it tries to click the second list item, it shows this error: stale element not found.
How can I make selenium click the web element, come back to the original page, and then click the next element without errors?