hoang nguyen hoang nguyen - 1 month ago 8
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

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

Answer

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:

http://darrellgrainger.blogspot.com/2012/06/staleelementexception.html