0
selenium.common.exceptions.StaleElementReferenceException: Message:         
    element reference: element is not attached to the page document

The page is loaded using JavaScript. On the page, there is a button "show more". When I click on this button, the data is displayed and the same "show more" button appears. This can continue many times. I can only click on the first button "show more", but on the following one does not work. I noticed that when the button is out of sight of the screen, then this exception arises!

    driver.execute_script ("arguments [0] .scrollIntoView ()" does not work.
      more_info [i] .WebDriverWait (driver, 3) .until(EC.element_to_be_clickable (By.CSS_SELECTOR, "selector")) doesn't work
more_info.location_once_scrolled_into_view
Please help me! i am begginer
my cod: (more_info is driver.find_elements(By.CSS_SELECTOR)

    def more_foo(more_info):
        more_info.location_once_scrolled_into_view  
        more_info.send_keys(Keys.CONTROL, Keys.ENTER)
        time.sleep(2)
1

1 Answer 1

1

StaleElement exception means that due to changes in the DOM, your element is now not attached to the DOM or has been deleted entirely. Read more about the exception here.

There is a solution mentioned here, which I have implemented and works perfectly. You should try the same - the code is in .js though.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.