Python Selenium chromedriver : StaleElementReferenceException: Message: stale element reference: element is not attached to the page document .. some notes

When switching to using chromedriver and away from PhantomJS these messages were everywhere. They are a bit misleading.

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

A lot of these can be fixed with waiting for the element to fully load before trying to access it. In the cases we ran into, almost all stale element references were due to javascript not fully loaded before the element could be accessed.

A simple time.sleep() would immediately fix it. Then we searched for more elegant ways to wait for the element.

The error message mentions stale element which one might associate with old and outdated, but in fact it’s actually too new.