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)
Ratmir Asanov
  • 6,237
  • 5
  • 26
  • 40
L. I
  • 1
  • Possible duplicate of [StaleElementReference Exception in PageFactory](https://stackoverflow.com/questions/44838538/staleelementreference-exception-in-pagefactory) – undetected Selenium Feb 19 '18 at 07:33

1 Answers1

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.

demouser123
  • 4,108
  • 9
  • 50
  • 82