hoang nguyen hoang nguyen - 6 months ago 33
Java Question

How to avoid "StaleElementReferenceException" in Selenium?

I'm implementing a lot of Selenium tests using Java. Sometimes, my tests fail due to a

. Could you suggest some approaches to making the tests more stable?


This can happen if a DOM operation happening on the page is temporarily causing the element to be inaccessible. To allow for those cases, you can try to access the element several times in a loop before finally throwing an exception.

see this excellent solution: