nightwatch icon indicating copy to clipboard operation
nightwatch copied to clipboard

Stale element reference errors should report the element and/or line of code it considers stale

Open reallymello opened this issue 10 months ago • 2 comments

Description

Often when automating pages that do in place updates of the DOM or if the same selector exists between state transitions Nightwatch may report a stale element reference in the test output during test execution (depending how defensively the test is written). While the error is logged, Nightwatch does not report which element or line of code it is executing that it considers stale which makes troubleshooting and resolving the error difficult--especially in large test suites. Often I have to set breakpoints and slowly narrow in on sections of code until I find it which can be very time consuming in larger test suites.

Suggested solution

Log the selector considered stale and/or the line of code so one can quickly identify what step is encountering a stale element exception.

For newer users, including the possible cause/solution messages similar to what was added for other error types may be helpful as well.

Alternatives / Workarounds

No response

Additional Information

No response

reallymello avatar Apr 10 '24 11:04 reallymello

Thank you for providing the details. I am looking into it. I was able to come up with a solution that logs the selector for stale element reference error. I am now trying to enhance that to add the link of code to it.

pujagani avatar May 29 '24 14:05 pujagani

Amazing, thank you

reallymello avatar May 29 '24 22:05 reallymello