Script mode for browser monitor configuration

To use this feature you need Dynatrace version 1.155 or later.

You can use the GET cluster version API call to find out which version you're using.

In addition to the usual configuration in the UI, you can use the script mode to configure your clickpath or single-URL monitors. In this mode you can access the underlying JSON script of your monitor. If you're a synthetic power user, this will make your life a lot easier and allow you to speed up clickpath creation and management. Use the script editor to quickly find specific events (steps), adapt locators across the whole script, or edit parts of the clickpath without re-recording.

You aren't limited to just one mode—you can switch back and forth between the UI and script modes by clicking the Clickpath/Script switch.

Access the clickpath script

To edit your clickpath monitor in the script mode

  1. Select Synthetic from the navigation menu.
  2. Select the clickpath monitor you want to edit.
  3. Click the Browse (...) button and select Edit.
  4. Click the Recorded clickpath tab in the left menu.
  5. Click Script in the Clickpath/Script switch.

Access the single-URL script

To edit your single-URL monitor in the script mode

  1. Select Synthetic from the navigation menu.
  2. Select the single-URL monitor you want to edit.
  3. Click the Browse (...) button and select Edit.
  4. Click the Monitor script tab in the left menu.

Edit the script

You can download the script—or just copy it from the editor—and edit it into a text editor of your choice.

However, you can also edit the script directly in the browser. This provides the following benefits:

  • Autocomplete feature—just press Ctrl+space to see the list of suggestions.
  • Syntax highlighting makes it easier for you to write script code.
  • Instant error validation. The editor instantly shows a warning for any error in the script. Hover your cursor over it to see what's wrong and a suggestion for how to fix it. You're unable to save changes until the code is error-free.

You can play your changes back without saving them—just click Play back clickpath at the top of the page.

Script structure

Main script object

Contains your monitor's script.

Element Type Description Required
configuration ScriptConfig The setup of the monitor. optional
type string The type of the monitor. Possible values are:
  • clickpath for clickpath monitors.
  • availability for single-URL browser monitors. These monitors are only allowed to have one event of the navigate type.
required
version string Version of the script. Use the 1.0 value here. required
events Array of:
navigateEvent
interactionEvent
javaScriptEvent
selectOptionEvent
cookieEvent
keystrokesEvent
Steps of the clickpath. The first step must always be of the navigate type.

Note that an event is not the same thing as an action—only events that trigger web requests are called actions, so your script might not have as many actions as events. Synthetic actions (similar to user actions for real user monitoring) hold the performance data collected during the playback of clickpath events.

The actual JSON object of the event depends on its type:
  • navigateEvent—contains a Navigate event.
  • interactionEvent—contains a Click or a Tap event.
  • javaScriptEvent—contains a JavaScript event.
  • selectOptionEvent—contains a Select option event.
  • cookieEvent—contains a Cookie event.
  • keystrokesEvent—contains a keystroke event.
required

The ScriptConfig object

Contains the setup of the monitor.

Element Type Description Required
userAgent string The user agent of the request. optional
device customDevice
or
predefinedDevice
The emulated device of the monitor. Holds either parameters of the custom device or name and orientation of the pre-configured device.

If not set, then the Desktop pre-configured device will be used.
optional
bandwidth bandwidthOptions
or
predefinedBandwidth
The emulated network conditions of the monitor.

If not set, then the full available bandwidth is used.
optional
requestHeaders requestHeader[] The list of HTTP headers to be sent with requests of the monitor. optional
requestHeaderFilters string[] Limits the usage of request headers. Only requests, matching the specified criteria will use headers from the requestHeaders element. optional
cookies requestCookie[] List of cookies to be created for the monitor.

These cookies are added before execution of the first step.
optional

The customDevice object

Contains the emulated device of the monitor.

Element Type Description Required
mobile boolean The flag of the mobile device.

Set true for mobile device or false for desktop or laptop.
required
touchEnabled boolean The flag of the touchscreen.

Set true if the device uses touchscreen. In that case use can set interaction event as tap.
required
width integer The width of the screen, pixels.

The maximum allowed width is 1920.
required
height integer The height of the screen, pixels.

The maximum allowed height is 1080.
required
scaleFactor integer The pixel ratio of the device. optional

The predefinedDevice object

Contains one of the pre-configured device emulations.

Element Type Description Required
deviceName string The name of the pre-configured device. When editing in browser, press Crtl+space to see the list of available devices. required
orientation string The orientation of the device—portrait or landscape.

Desktop and laptop devices are not allowed to use the portrait orientation.
required

The bandwidthOptions object

Contains the emulated network conditions of the monitor.

Element Type Description Required
latency integer The latency of the network, in milliseconds. required
download integer The download speed of the network, bytes per second. required
upload integer The upload speed of the network, bytes per second. required

The predefinedBandwidth object

Contains the pre-configured network emulations.

Element Type Description Required
networkType string The type of the pre-configured network. When editing in browser, press Crtl+space to see the list of available networks. required

The requestHeader object

Contains the list of HTTP headers to be sent with requests of the monitor.

The following headers are not allowed:

  • user-agent
  • cookie
Element Type Description Required
name string The name of the HTTP header. required
value string The value of the HTTP header. required

The requestCookie object

Contains the list of cookies to be created for the monitor.

Every cookie must be unique within the list. However, you can use the same cookie again in other event.

Element Type Description Required
name string The name of the cookie.

The following cookie names are now allowed:
  • dtCookie
  • dtLatC
  • dtPC
  • rxVisitor
  • rxlatency
  • rxpc
  • rxsession
  • rxvt
required
value string The value of the cookie. The following symbols are not allowed: ;,\". required
domain string The domain of the cookie. required
path string The path to the cookie. optional

The navigateEvent object

Contains a Navigate event.

Element Type Description Required
type string The type of the synthetic event.

In this case it holds the navigate value.
required
url string The URL to navigate to. required
description string A short description of the event to appear in the UI. required
wait waitCondition The waiting condition for the event. Defines how long Dynatrace should wait before the next action is executed. optional
validate validationType[] The validation rule for the event. It helps you to verify that your browser monitor loads the expected page content or page element. optional
target targetType The tab on which the page should open. optional
authentication authenticationType The login credentials to bypass the browser login mask. optional

The interactionEvent object

Contains a Click or a Tap event.

Element Type Description Required
type string The type of the synthetic event.

In this case it holds the click or tap value.
required
description string A short description of the event to appear in the UI. required
button integer The mouse button to be used for the click. required
wait waitCondition The waiting condition for the event. Defines how long Dynatrace should wait before the next action is executed. optional
validate validationType[] The validation rule for the event. It helps you to verify that your browser monitor loads the expected page content or page element. optional
target targetType The element to click/tap on. optional

The javaScriptEvent object

Contains a JavaScript event.

Element Type Description Required
type string The type of the synthetic event.

In this case it holds the javascript value.
required
description string A short description of the event to appear in the UI. required
javaScript string The JavaScript code to be executed in this event. required
wait waitCondition The waiting condition for the event. Defines how long Dynatrace should wait before the next action is executed. optional
target targetType The tab where the JavaScript code is executed. optional

The selectOptionEvent object

Contains a Select option event.

Element Type Description Required
type string The type of the synthetic event.

In this case it holds the selectOption value.
required
description string A short description of the event to appear in the UI. required
selections listOptions[] The options to be selected. required
wait waitCondition The waiting condition for the event. Defines how long Dynatrace should wait before the next action is executed. optional
validate validationType[] The validation rule for the event. It helps you to verify that your browser monitor loads the expected page content or page element. optional
target targetType The selection tag of the dropdown. optional

The cookieEvent object

Contains a Cookie event.

Element Type Description Required
type string cookie required
description string A short description of the event to appear in the UI. required
cookies requestCookie[] The list of cookies to be created during the event.

Every cookie must be unique within the list. However, you can use the same cookie again in other event.
required

The keystrokesEvent object

Contains a Keystroke event.

Element Type Description Required
type string keystrokes required
description string A short description of the event to appear in the UI. required
textValue string The text to enter. required
masked boolean Indicates whether the textValue is encrypted (true) or not (false). required
simulateBlurEvent boolean Defines whether to blur the text field when it loses focus.

Set true to trigger the blur the textValue.
required
wait waitCondition The waiting condition for the event. Defines how long Dynatrace should wait before the next action is executed. optional
validate validationType[] The validation rule for the event. It helps you to verify that your browser monitor loads the expected page content or page element. optional
target targetType The object to enter the text to. optional

The waitCondition object

Contains the waiting condition for an event.

Element Type Description Required
waitFor string The time to wait before the next event is triggered. Possible values are:
  • page_complete—wait for the page to load completely.
  • network—wait for background network activity to complete.
  • next_action—wait for next action.
  • time—wait for specific period of time.
  • validation—wait for a specific element to appear.
required
milliseconds integer The time to wait, in milliseconds.

The maximum allowed value is 60000.
required for the time type

not applicable otherwise
timeoutInMilliseconds integer The maximum amount of time to wait for a certain element to appear, in milliseconds. If exceeded, the action is marked as failed.

The maximum allowed value is 60000.
required for the validation type

not applicable otherwise
validation validationType[] The element to wait for. required for the validation type

not applicable otherwise

The validationType object

Contains the validation rule for an event or waiting rule.

Element Type Description Required
type string The goal of the validation:
  • content_match—check page for the specific content. Not allowed for validation inside of wait condition.
  • element_match—check page for the specific element.
required
match string The content to look for on the page.

Regular expressions are allowed. In that case set isRegex as true.
required for content_match

optional for element_match
isRegex boolean Defines whether match is a plain text (false) or regular expression (true). optional
failIfFound boolean The condition of the validation:
  • false—validation succeeds if the specified content/element is found.
  • true—validation fails if the specified content/element is found.
required
target targetType The element to look for on the page. required for element_match

optional for content_match

The authenticationType object

The login credentials to bypass the browser login mask during a Navigate event.

Element Type Description Required
type string The type of the authentication—basic or webform.

Only the basic type is allowed in clickpath monitors.
optional
username string The username to log in with. required
password string The password to log in with.

It contains not the actual password, but a unique ID of it and the password itself is stored in Dynatrace and found by the ID. If you change the ID the stored password will became unavailable.

To change the password, set the masked property as false and type in the new password.
required
masked boolean The flag of the masked password.

true means that the password is encrypted and stored and the password field shows the ID of the password. to encrypt the password.

Set false to type in a new password.
optional

The listOptions object

Contains the options to be selected in the Select option event.

Element Type Description Required
index integer The index of the option to be selected. required
value string The value of the option to be selected. required

The targetType object

Contains the target tab or element of the event.

Element Type Description Required
window string The tab of the target. optional
locators locatorType[] The list of locators, identifying the desired element. optional

The locatorType object

Contains an element of a page to look for.

Element Type Description Required
type string Defines where to look for the element:
  • css—in CSS selector.
  • dom—in JavaScript code.
required
value string The name of the element to be found. required