Message: stale element reference: element is not attached to the page document in Python

To retrieve the details of contributions avoiding stale element reference you can use the following solution: Code Block: from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC years = [] options = webdriver.ChromeOptions() options.add_argument(“start-maximized”) options.add_argument(‘disable-infobars’) driver=webdriver.Chrome(chrome_options=options, executable_path=r’C:\Utility\BrowserDrivers\chromedriver.exe’) driver.get(“https://github.com/agronholm”) contributions = WebDriverWait(driver, 5).until(EC.visibility_of_all_elements_located((By.XPATH, “//div[@class=”profile-timeline-year-list js-profile-timeline-year-list bg-white js-sticky … Read more

Selenium Webdriver – Stale element exception when clicking on multiple dropdowns while HTML DOM doesn’t change

When you select Insurance Test Client then only you get the option Product Insurance, which essentially means the HTML DOM gets changed, which results in StaleElementException. To avoid that, once we select from the first dropdown, we need to induce some wait for the elements of the second dropdown to render in the HTML DOM. … Read more

StaleElementException when iterating with Python

If you just want your script to iterate over all the result pages, you don’t need any complicated logic – just make a click on Next button while it’s possible: from selenium.webdriver.common.by import By from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.support.ui import WebDriverWait as wait from selenium.common.exceptions import TimeoutException driver = webdriver.Chrome() driver.get(‘https://www.amazon.com/s/ref=nb_sb_noss_1?url=search-alias%3Daps&field-keywords=sonicare+toothbrush’) while … Read more

StaleElementReference Exception in PageFactory

StaleElementReferenceException StaleElementReferenceException extends WebDriverException and indicates that the previous reference of the element is now stale and the element reference is no longer present on the DOM of the page. Common Reasons The common reasons behind facing StaleElementReferenceException are as follows: The element has been deleted entirely. The element is no longer attached to the … Read more