When running in a Ruby kernel on Jupyter Notebook, after finding and clicking an element that changes the page and removes the clicked element, I get this error after about 3 seconds:
Selenium::WebDriver::Error::StaleElementReferenceError: stale element reference: element is not attached to the page document
The click itself works and I am not trying to do anything with the clicked element afterwards. If I try to find another existing element right after the click, I do not get the above error from the first click.
The following works fine w/o any error:
click_button 'My Button'
find_button 'My New Button'
Is this expected behavior? Why does it give an error a few seconds after the click but not if a new element is searched for right after the click?