3693 views

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

 

  1. Run an Automated Test Framework test that interacts with a form.

  2. 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

This is expected behaviour. The Automated Test Framework is working correctly when it reports this error on the output of a Step Result during the test.

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.

When an Automated Test Framework test fails in this manner it is reporting an error found on the page being tested. The following helps users identify the root cause of the error that page caused.
 
To identify and resolve script errors reported by the ATF:
  1. Open the developer tools browser console on the Client Test Runner page.
  2. Navigate to Automated Test Framework > Tests and run the test, so that it is picked up by the same Client Test Runner.
  3. 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.
  4. 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
  5. 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

When a client script causes an error, the browser console displays an error similar to this:
***************************************************
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
In this case the client script Modify Comments Label caused the error.

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

Seen In

There is no data to report.

Associated Community Threads

There is no data to report.

Article Information

Last Updated:2018-09-11 12:33:28
Published:2018-09-04