0

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:

enter image description here

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?

dansalmo
  • 11,506
  • 5
  • 58
  • 53
  • Where are you doing this? In a running program? irb? byebug? – Thomas Walpole Mar 04 '21 at 04:08
  • I would only expect it if you’re outputting (or using) the return value of the click_button call since it’s the element which is going away – Thomas Walpole Mar 04 '21 at 04:52
  • can you post the unit test code here so we can debug it step by step? – beniutek Mar 04 '21 at 11:55
  • I am sorry, it is not happing in a running test. It was happening when doing initial development using Jupyter Notebook running a Ruby kernel. The notebook must be using the return value for some time after the cell runs. I will update the question. Thank you for your help. – dansalmo Mar 07 '21 at 19:09

0 Answers0