Scripting reference

Reference guide for scripting synthetic tests

1. Getting started

Before you get started, refer to the Test scripting document for a review of how to add synthetic scripts to your test configuration. Here are the basics you need to know before writing your first script.

// Comments like these are ignored

// So are blank lines
  • Each line of the script contains a command and any parameters.
  • Parameters are tab delimited
  • A script timeout of 120 seconds is enforced for all tests

2. Operating on the DOM

Commands operating on the DOM identify the element with a format of attribute=value
If you are filling out a form and you want to populate an element like this:

<input type="text" class="tabInputFields" id="lgnId1" value="" tabindex="1" 
maxlength="99" name="loginId"/>

You can identify the element as id=lgnld1, name=loginId or tabindex=1. The class attribute is special and is referenced as className. Use the name attribute when possible for form fields.

In addition to attribute matching, you can match on innerText and innerHtml. Both will match the contents of the DOM element instead of the attributes.

<div dojoattachpoint="containerNode" class="label">Delete</div>

This can be identified by innerText=Delete. Matching is case sensitive and matches on the full string.

3. Multi-step scripts

SpeedCurve does not report data for multi-step scripts separately. If scripting a multi-step transaction, you need to disable data logging for intermediate steps.

// Supress data logging
logData 0

// Navigate through a user journey

// Enable data logging
logData 1

// Record this step

Explore these additional recipes for scripting multi-step scripts.

4. Working with variables

In order to simplify your scripts and help with script maintenance, variable may be used.

Replacing URL for a test using %URL%

navigate %URL%
// output: navigate

Host of the URL for the test (not including protocol) using %HOST%

setDnsName %HOST% dns.example
// output: setDnsName dns.example

Origin of the URL (includes protocol and port if defined) using %ORIGIN%

setCookie  %ORIGIN% foo=bar
// output: setCookie foo=bar

setCookie  %ORIGIN% foo=bar
// output: setCookie foo=bar

%HOST_REGEX% – Using HOST compatible with regular expressions by escaping dots

setHeader  Foo: Bar  %HOST_REGEX%
// output: setHeader Foo: Bar  speedcurve\.com

%HOSTR% – Using the final host name of the URL after following redirects

setDnsName %HOSTR% dns.example
// output: setDnsName dns.example

%TEST_ID% – replaced with the id of the current test

// URL:

navigate    %URL%/?tag=%TEST_ID%

// output: navigate

5. Command reference

Navigating and Interacting with the DOM


Navigates the browser to the provided url.

// usage: navigate <url>


Triggers a click event for the identified element. This DOES NOT have an implied wait after the event.

// usage: click <attribute=value>
click   id=Go


Triggers a click event for the identified element and waits for the browser activity to complete.

// usage: clickAndWait <attribute=value>
clickAndWait    innerText=Publish


Selects a value from a dropdown list of the element.

// usage: selectValue   <attribute=value>   <value>
selectValue id=country  usa

sendClick / sendClickAndWait

Creates a javascript OnClick event and sends it to the indicated element.

// usage: sendClickAndWait  <attribute=value>
sendClickAndWait    innerText=Send

sendKeyDown / sendKeyUp / sendKeyPress (AndWait)

Creates a javascript keyboard event (OnKeyDown, OnKeyUp, OnKeyPress) and sends it to the indicated element.

// usage: sendKeyDownAndWait    <attribute=value>    <key>
// <key> - Key command to send (special values are ENTER, DEL, DELETE, BACKSPACE, 
sendKeyDownAndWait  name=user    x


Sets the innerHTML of the given DOM element to the provided value. INCLUDES HTML formatting.

// usage: setInnerHTML  <attribute=value>   <value>
setInnerHTML    myContent   %MSG%


Sets the innerText of the given DOM element to the provided value. DOES NOT INCLUDE HTML formatting.

// usage: setInnerText  <attribute=value>   <value>
setInnerText    myContent   %MSG%


Sets the value attribute of the given DOM element to the provided value. Currently only "input" and "textArea" element types are supported.

// usage: setValue  <attribute=value>   <value>
setValue    name=loginId    userName


Triggers a submit event for the identified form.

// usage: submitForm    <attribute=value>
example: submitForm name=AOLLoginForm


Executes javascript.

// usage: exec  <javascript code>
exec    window.setInterval('window.scrollBy(0,600)', 1000);


Executes javascript and waits for the browser to complete any activity generated from the action.

// usage: execAndWait   <javascript code>
execAndWait window.setInterval('window.scrollBy(0,600)', 1000);

End conditions


Sets the "Activity Based Measurement" mode.
Valid values are:

  • 0 - Disabled (Web 1.0 - Measure based off of document complete)
  • 1 - Enabled (Web 2.0 - Measure until activity stops)
    The default if not specified in the script is 1 (Enabled) Browser Support: IE, Chrome, Firefox
// usage: setABM    <mode>
setABM  0


Overrides the timeout value for the time after the last network activity before a test is considered complete (defaults to 2000 which is 2 seconds).

// usage: setActivityTimeout    <timeout in milliseconds>
setActivityTimeout  5000


Overrides the timeout value for the individual script steps.

// usage: setTimeout    <timeout in seconds>
setTimeout  60

Request Manipulation


Blocks individual requests from loading. The command matches the list of things to block against the full url of each request (including host name).

// usage: block    <block strings>
block    adswrapper.js


Blocks all requests from the given domains from loading. Takes a space-delimited list of full domains to block.

// usage: blockDomains    <block domains>
blockDomains    adswrapper.js


Blocks all requests not from one of the given domains from loading. Takes a space-delimited list of full domains to allow.

// usage: blockDomainsExcept    <allow domains>

Explore this recipe for further examples of request blocking.


Stores a browser cookie to be used while navigating.

// usage: setCookie <path>  <value>
setCookie   zip=80212
// setting multiple cookes for a path
setCookie   TestData = Test; expires = Sat,01-Jan-2031 00:00:00 GMT


Allows for overriding the IP address to be used for a host name. The override is effectively the same as populating an entry in the hosts file and will eliminate the DNS lookup times.

// usage: setDns    <host name> <IP Address>


Allows for overriding a host name (creating a fake CNAME). Browser Support: IE, Chrome, Firefox

// usage: setDnsName    <name to override>  <real name>

Explore this recipe for further examples of DNS manipulation.


Overrides the User Agent string sent by the browser.



You will still be using the same browser engine so you are still limited by the capabilities and behavior of that browser even if you are spoofing another browser.

// usage: setUserAgent    <user agent string>
setUserAgent    Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1A543 Safari/419.3


Replaces the value of the Host: HTTP header for the given host with the provided replacement. It also adds a new header (x-Host:) with the original value.

// usage: overrideHost  <host>    <new host>


For all requests to the given host, rewrite the requests to go to a different server and include the original host in the new URI.

// usage: overrideHostUrl   <host>    <new host>


Adds the specified header to every http request (in addition to the headers that exist, DOES NOT overwrite an existing header).

// usage: addHeader <header>    {filter}
addHeader   Pragma: akamai-x-cache-on


Adds the specified header to every http request, overriding the header if it already exists.

// usage: setHeader <header>    {filter}
setHeader   UA-CPU: none-ya


Clears any headers that were specified through addHeaders or setHeaders (in case you want to only override headers for part of a script).

// usage: resetHeaders



Causes multiple script steps to be combined into a single "step" in the results

// usage: combineSteps  [count]

// Sample Script:


Conditionally execute a block of script code based on run number or cached state for the test. Conditional blocks can be nested.

// usage:  if   [cached|run]    <value>
//        else
//        endif

if    run    1
    if    cached    0
        <do something for first view of first run>
    <do something else for everything but first run>


Expires any cache entries that will expire within the specified number of seconds. This can be used to simulate a repeat view after a certain amount of time (for example, what it would be like to browse the page the next day). It does not help with simulating content changes but any resources with a short expiration will end up being checked with if-modified-since requests.

// usage: expireCache   <seconds>
expireCache 86400


Specifies a geolocation override position.

// usage: setLocation   <lat>,<lng>    <accuracy>
setLocation    38.954980,-77.447956    10


Pauses the script operation for a given number of seconds.

// usage: sleep <seconds to sleep>
example: sleep  5


Removes PTST/SpeedCurve from the User Agent string

// Usage: remove PTST/SpeedCurve from User Agent string
speedcurve_removePTST 1


Clears the OS certificate caches which causes IE to do OCSP/CRL checks during SSL negotiation if the certificates are not already cached.

// Usage: Clears certificate chache in IE
speedcurve_clearcerts 1

What’s Next

For synthetic scripting examples, check out: