Synthetic Classic has reached end of support and is no longer available. Existing Synthetic Classic customers have been upgraded to the all-in-one Dynatrace software intelligence platform.

Debug alerts custom JavaScript

The Recorder and Browser Agents provide a way to add alert statements to custom JavaScript code within a script to help debug code. Alerts can be inserted anywhere JavaScript is accepted within a script (Custom Actions, Reply Handlers, Event Hooks, and so on).

Alert calls in JavaScript typically result in an alert dialog box appearing when the alert() call is executed. The browser agents are designed to dismiss alerts, by design, so the agents will instead log the alert messages and output them in an alert.log file that is generated anytime the script is run in the Recorder and is present in the SCoE archive created when a SCoE enabled test fails during playback on the Synthetic Classic Portal.

To get alert output during script playback, add a JavaScript alert() to your code, feeding it arguments that will evaluate and return a string value. For example:

 randomNumber = Math.random()\*1000;
alert('randomNumber = ' + randomNumber);

When this sample code is run on the browser agent, the output in the alert.log file will be JSON-formatted and will look something like this:

"type": "alert",
"timestamp": "1318957784192",
"window": "control",
"step": 2,
"action": 3,
"message": "randomNumber = 473"

The agents will report the following properties for each alert generated:


The millisecond representation of the time that the alert was triggered on the local system running the test. Dynatrace test locations report times in Universal time (GMT).


The window that the alert occurred: gomez_top[0].frames[1], control, etc.


The step that the alert occurred. This value is 0-based: the first step is numbered 0, not 1.


The action in which the alert occurred. This value is 0-based.


The string output from the alert, properly encoded to handle escape sequences and Unicode characters.

The Recorder displays the step, action, and message contents for each alert in the alert.log file in the playback results. The output can be found in the Debug tab of the script and page-level results.