Description
An Automated Test Framework test reported Failure, and its Test Result has a Step Result with the following summary:
This step failed because a client-side Javascript error was detected on the page being tested. See the logs and screenshots on the test result for details.
Steps to Reproduce
-
Run an Automated Test Framework test that interacts with a form.
-
Check the Test Results for this test, for a Step Result with the following Summary:
This step failed because a client-side JavaScript error was detected on the page being tested. See the logs and screenshots on the test result for details.
This Step Result appears only on a step that interacts with the UI.
Workaround
In the event of a browser Javascript error, the Automated Test Framework fails the test on the step that is being executed when it occurred. The purpose of this error message is to help developers and testers find customization issues on their instance that occurred while executing that test step.
Even though Client Scripts can fail silently on Javascript errors while executing procedures, the error may still impact data and the procedure being executed, so the Automated Test Framework considers these errors as a validation failure.
- Open the developer tools browser console on the Client Test Runner page.
- For information about how to open the browser console, see the following article: How do I open the JavaScript console in different browsers?
- Navigate to Automated Test Framework > Tests and run the test, so that it is picked up by the same Client Test Runner.
- After the test completes, review the browser window's console for script errors. JavaScript errors found in the console were caused by the page or pages being tested.
- If you can see the error, then try to identify and troubleshoot the problematic script, which may be on any of the following base system tables:
- Client Script
- UI Action
- UI Macro (HTML script)
- UI Page (HTML script)
- UI Policy
- UI Script
- Tables that extend the above base system tables
- Review the script for errors and once it has been fixed, run your test again.
To track down what introduced the script error, you can review that script's version history from the Versions related list of that script record.
- If you've customized a base system script, it's possible that during an upgrade of your instance, a base system version of that script - that had been changed in the upgraded ServiceNow release - was skipped, and that change needed to be propagated to the customization.
Client Script error examples
***************************************************
A script has encountered an error in render events
TypeError: Cannot read property 'id' of undefined
Script ends. Continuing happily
***************************************************
[00:00:00.002] onLoad Modify Comments Label
Any other type of script error reports directly to the browser console without any formatting upon occurrence, i.e:
TypeError: callbacks[id] is undefined
Script resource links
In some cases the console error provides a link to the script resource file. Following this link may give context to which script had executed it, i.e.:
Uncaught ReferenceError: myobj is not defined
at incident.do?sys_id=12345678901234567890123456789012
(anonymous) @ incident.do?sys_id=12345678901234567890123456789012 <---- LINK
Access to scripts
While identifying problematic scripts, be sure to have necessary permissions and check relevant domains if they're configured.
Related known problems on Service Catalog "use cart layout"
https://hi.service-now.com/kb_view.do?sysparm_article=KB0682516
https://hi.service-now.com/kb_view.do?sysparm_article=KB0656699
Related Problem: PRB1037062