Oct-18-2019, 03:04 AM
Can somebody tell me why I keep getting a StaleElementReferenceException. Im doing a simple script that navigates to a page. Grabs the links and puts them into a list. Then navigates to each one of those links. It navigates to the first list item then I get the error.
The element reference of <a href="https://www.famousgraphicdesigners.org/alan-aldridge"> is stale; either the element is no longer attached to the DOM, it is not in the current frame context, or the document has been refreshed
Thanks in advance.
The element reference of <a href="https://www.famousgraphicdesigners.org/alan-aldridge"> is stale; either the element is no longer attached to the DOM, it is not in the current frame context, or the document has been refreshed
Thanks in advance.
from selenium import webdriver driver = webdriver.Firefox() driver.get("https://www.famousgraphicdesigners.org/") links = driver.find_elements_by_xpath('//*[@id="pages-2"]/div/ul/li/a') links_total = len(links) print("Found", links_total, "total links.\n") for i in links: driver.get(i.get_attribute('href')) driver.quit()