Checkout our demo site to practice selenium https://magento.softwaretestingboard.com/

0 like 0 dislike
380 views
by Contributing Tester (99 points)

I am writing a code and I get lots of "Stale Element Reference Exception".

What is the best way do you suggest to avoid "Stale Element Reference Exception"?

Here is the exception details.

https://www.seleniumhq.org/exceptions/stale_element_reference.jsp

2 Answers

0 like 0 dislike
by
Driver.navigate().refresh();

use do-while loop.

0 like 0 dislike
by Master (1.2k points)
You can use Suppliers https://docs.oracle.com/javase/8/docs/api/java/util/function/Supplier.html

Suppliers will help you retrieve fresh element everytime.

This way you can retrieve stale element reference exception.


This site is for software testing professionals, where you can ask all your questions and get answers from 1300+ masters of the profession. Click here to submit yours now!

...