nightwatchjs / nightwatch

Integrated end-to-end testing framework written in Node.js and using W3C Webdriver API. Developed at @browserstack
https://nightwatchjs.org
MIT License
11.79k stars 1.31k forks source link

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

Closed reallymello closed 2 weeks ago

reallymello commented 5 months ago

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

pujagani commented 4 months ago

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.

reallymello commented 4 months ago

Amazing, thank you