DéjàClick Script Variables
A prerequisite for using this guide is to be familiar with DéjàClick recording and uploading. If you don't have the DéjàClick toolbar in your Firefox browser, and/or you have never used DéjàClick before, please go to the
DéjàClick Quick Start Guide. After you have become comfortable with recording DéjàClick transactions, you'll be able to move on to this more advanced feature.
Script Variables Features
DéjàClick Script Variables are dynamic and can be pinned to a specific monitoring location. Here are several cases of special transaction monitoring requirements that Script Variables could be used to support:
- Login using a different user_id from each AlertSite monitoring location
- Execute a registration transaction that requires a unique email address using “built-in” variables
- Use relative date variables to consistently populate reservations searches with future dates
- Perform specialized keyword checks; navigate to a different URL depending on the monitoring location
Script Variables are constructed from one or more tokens of the following types:
- static text
- random text
- random number
- auto-increment
- relative date/time
- dataset value
- replay location
- JavaScript code
The
dataset value allows a .CSV type file (comma-separated values) to be imported into the script for referencing required input data. Other field separator characters may also be used.
Record a Transaction
First, let's record a transaction with DéjàClick. To make our examples simple, we'll use www.google.com. Click the Record button

to power on DéjàClick and start recording.
Click in the Google search bar, enter some text and click
Google Search. We'll use “name@domain.com” for the initial search. When the search completes, click the green Stop Record/Replay button

to stop recording, and then
OK in the confirmation dialog. This records a script containing 2 actions and 4 events.
Open the Script Results sidebar by clicking the green check-mark

in the DéjàClick toolbar, The sidebar has 3 parts:
- DéjàClick action and events tree
- The Results tab
- The Properties tab
Click in the top of the sidebar heading to expand the DéjàClick steps and display Scripts->Actions->Events, then click the Replay button

to replay the recording:
Examples
This section provides four examples for using script variables:
- generating a Google search using a random string variable,
- an advanced Google search using datasets,
- variable keywords, and
- variables limited by location.
Several steps are required to set up a Script Variable. Once you know what variables you want to use in your recording, it's a simple process.
Example 1 – Random String Script Variable
For our first example, we will generate random email addresses in the Google search box. We'll construct the email address script variable, which we will name
Random Email Address, using 3 “tokens”: a
4-character random string, a
3-digit number, and the static string “
@mydomain.com”.
- Click on Input HTML Element event in the DéjàClick sidebar script tree
- Click the Properties tab
The sidebar will present the list of properties for the Input HTML Element event:
Next we will configure the script variable.
- If the Event Input properties panel is not open, click Event Input to expand the Event Input properties panel
- Click the checkbox for Use script variable
- Click the Create a new script variable icon to the right of the Select... dropdown
Complete the
Add Script Variable dialog box (shown below) by providing a name for the custom variable and the tokens to be used to construct the variable:
Enter
Random Email Address in the
Name field of the Add Script Variable dialog, then click the
Add... button to display the
Add Token dialog box:
The
Type dropdown list contains:
- Static Text
- Random Text
- Random Number
- Auto Increment
- Relative Date/Time
- Dataset Value
- Replay Location
We will create the Random Email Address script variable with 3 tokens: one using
Random Text, one using
Random Number, and one using
Static Text. Note that
Parameters change depending on the
Type.
- Select Type: Random text
- Enter minimum length 4 characters
- Enter maximum length of 4 characters
- Leave Location ID blank
The Add Token dialog box will appear as follows:
Click
OK to save. Now the Add Script Variable dialog box will contain:
Add the next token, the 3-digit random number. Click
Add... and fill in the Add Token dialog as follows:
- Select Type: Random number
- Enter minimum value 0
- Enter maximum value 999
- Leave Location ID blank
- Click OK to save.
The Add Script Variable dialog box will appear as follows:
Click
Add... to create the third and final token, a static string
@mydomain.com. Fill in the Add Token dialog as follows:
- Select Type: Static text
- Enter string @mydomain.com in the Value: field
- Leave Location ID blank
Click
OK to save. The Add Script Variable dialog box will now contain:
Click the
Preview... button to display a sample of what the variable will look like during replay, for example:
Click
OK to dismiss the preview box, then click
OK to complete the script variable construction. The
Event Input section of the sidebar will now contain:
Make certain to click the Apply button to assign the script variable as the event input value.
Now you are ready to replay the recording using the randomly generated email addresses in the Google search bar. Each time you replay the recording by clicking

, a new email address will be generated and searched for. Here are some illustrations:
Note the change in email address each time the recording is replayed, created by concatenating the 4-character token, 3-digit token, and static string “@mydomain.com”.
Example 2 – Dataset Script Variable
If your recording includes filling in a form, you can create a file, called a dataset, that contains the information for the form. Script variables can be configured to selectively parse the dataset for the data values to use.
NOTE: This feature is supported on the Desktop plug-in only. It is not supported in the AlertSite monitoring locations.
As an example, we will record a few steps that includes an Advanced Search in Google, which displays a multiple field form rather than a simple search box. We arrive at the page below by recording the following actions:
- Start recording
- Enter www.google.com in the address bar and hit <ENTER>
- Click Advanced Search next to the search bar
- Click in the box for “all these words”
- Input “name”
- Tab to the box for “this exact wording or phrase”
- Input “type”
- Tab to the next box
- Stop recording
This set of steps produces the following web page after replay:
The first
Input HTML Element event in Action 3 of the recording corresponds to the "all these words" field and the second
Input HTML Element event corresponds to the field for "this exact wording or phrase". The search strings "name" and "type" are simply placeholders for the recording.
Create a text file with an equal number of comma-separated set of strings on two lines:
horse,tiger,mousepalomino,white,tiny
Note: This file must reside in the directory configured for Datasets in the
Configuration Options Paths dialog:
To select a different location for Datasets, click on "Change..." next to the Dataset Folder field and select or create a different directory.
For this example, we'll call this text file
dataset1.csv. The Dataset Script Variable will be configured to rotate through the first row for the first Input HTML event and the second row for the second Input HTML event.
First, let's import our dataset data into the script:
- Click on the top step in the Script steps section of the sidebar to get to script level (Script Variable Example 2 in the screenshot above)
- Click on the Properties tab in the lower section of the sidebar
- Click on Datasets (10th down the list of Properties) to expand the item
- Click the Add button to add dataset information
- In the Name field of the Add Dataset dialog, enter a name for your dataset, e.g., animals
- Click Choose... to select the filename
dataset1.csv you created above
- Leave the Import dataset into script option checked
- Click Preview... to verify the data looks correct
- Click OK
The dataset
animals with the values in
dataset1.csv is now associated with the script. The next step is to have the two input fields configured to utilize the data in the dataset. So our next step is to create two script variables and assign them to the two input fields.
- Click on the first Input HTML Element line in the script step window at the top of the sidebar
- Click Event Input in the Properties tab at the bottom of the sidebar to expand the item
- Click the checkbox next to Use script variable
- The sidebar will appear as:
- Click the Create a new script variable icon to the right of the Select... dropdown
- Enter a name, e.g., animal names, in the Name field of the Add Script Variable dialog
- Click the Add... button to add a token
- In the Add Token dialog, select Dataset value from the Type dropdown
- animals (2x3) will already populate the Dataset parameter field since it was already added at the script level (2x3 refers to the number of rows and columns in the dataset file)
Note: You may also add new datasets from within the Add Token dialog box if you desire.
- Enter 1 in Start row, since the first Input HTML Element uses the first row in the dataset file
- Enter 0 in Increment next to Start row, since you want to stay on this row through each replay
- Enter 1 in Start column, since this is the column you want to start with
- Enter 1 in Increment next to Start column, since you want to move to the next column in this row with each replay
The Add Token dialog will look like this:
- Click OK to add the token to the script variable
- Click OK to save the script variable within the script
- Click Apply in the Event Input properties to apply the script variable to this input field
To use the dataset input for the second
Input HTML Element field, repeat the steps above with the difference being the name of the script variable and start row.
- Click on the second Input HTML Element line in the script step window at the top of the sidebar
- Click Event Input in the Properties tab at the bottom of the sidebar to expand the item if necessary
- Click the checkbox next to Use script variable
- Click the Create a new script variable icon to the right of the Select... dropdown
- Enter a name, e.g., attributes, in the Name field of the Add Script Variable dialog
- Click the Add... button to add a tokenIn the Add Token dialog, select Dataset value from the Type dropdown ( animals (2x3) will already appear in the Dataset parameter field)
- Enter 2 in Start row, since the second HTML Input Element field is for the second row in the dataset file
- Enter 0 in Increment next to Start row, since you want to stay on this row through each replay
- Enter 1 in Start column, since this is the column you want to start with
- Enter 1 in Increment next to Start column, since you want to move to the next column in this row with each replay
The Add Token dialog will look like:
- Click OK to add this token to the script variable
- Click OK to save the script variable within the script
- Click Apply in the Event Input properties to apply the script variable to this input field
You are now ready to replay the recording using the dataset values as input. Replay the recording 3 times, and you will see the two input fields change tokens automatically, as shown below:
First replay:
Second replay:
Third replay:
To start with the initial set of tokens (horse, palomino), reset the current replay count as follows (this is entirely optional):
- Click on the Configure Options button
in the DéjàClick toolbar
- Select Configure Settings
- Click on the Replay Properties tab
- Click Reset on the Variable Options line
Example 3 – Script Variable as a Keyword
Under certain circumstances, your web page may render differently from one location to another. For example, say you monitor from Los Angeles (Location ID 42), NY (Location ID 70), and London (Location ID 5010), and your page has the title “Labor Relations”, which you want to keyword. However, when the page is tested in London, the title becomes “Labour Relations” because your hosting server detects that it's a UK location and renders the same content but with UK spellings. You can set up a script variable to select a different keyword when it's tested on the London monitoring station.
Note: Location IDs are found in the Console Help dialog screen under
Monitoring Locations.
After recording your script, do the following:
- Click on the script name in the sidebar to get to script level
- Click the '+' next to Variables in the Properties tab to open
- Click Add to open the Add Script Variable dialog box (same as in Example 1)
- Enter a name for the variable, e.g., KW Labor or Labour
- Click the Add... button to bring up the Add Token dialog box (same as in Example 1)
- Leave the default Type Static text
- In the Parameters field, enter the keyword Labor Relations
- In the Location ID: box in the Limit token to field, enter 42 for Los Angeles
- Click OK to add the token.
- Click Add... again in the Add Script Variable dialog and add another Labor Relations static token, but enter 70 in the Location ID: box for New York, then click OK to add the token
- Click Add... one more time to create our third static token, but this time enter Labour Relations in the Parameter field, and 5010 for London in the Location ID: box, then click OK.
- The Add Script Variable dialog will contain:
Note the checkbox labeled
Calculate variable only once (sticky value) in the
Add Script Variable dialog. Checking this box will maintain the value of the variable throughout the recording. For example, if you want to use the same value in Steps 2, 5 and 8, check the box and the variable will be calculated in Step 2 and the same value used in Steps 5 and 8 during the same monitoring interval.
Next, let's create our Keyword Validation. Keywords may be added to either
Actions or
Events. In this example, let's add our keyword to the first event
- Highlight the event Navigate URL (Event 1 of Action 1 in this example)
- Click Keyword Validation in the Properties tab to expand the property panel
- Click Add to open the Add Keyword Validation dialog box
- Check the box next to Use variable: and in the Select... dropdown, choose KW Labor or Labour
- Click OK to add the script variable Keyword Validation
Subsequent replay will succeed with keyword Labor Relations when monitored from LA or NY, and with Labour Relations when monitored from London.
Example 4 – Location-Limited Tokens
One monitoring strategy may be to populate your web form with different strings when monitoring at different locations. For this example, we'll use the Google Search script from Example 1. We'll construct a script variable using tokens that are limited by our 3 monitoring locations, Los Angeles (42), New York (70), and London (5010).
For illustration purposes, our script variable will be created with 5 static string tokens:
ABC
DEF
GHI
JKL
MNO
String DEF will be limited to Los Angeles, GHI will be limited to New York, and JKL limited to London. Strings ABC and MNO will not be limited to a specific monitoring station. As such, the search strings you will see in the Google Search box are:
| Location (ID) | Search String |
| Los Angeles (42) | ABCDEFMNO |
| New York (70) | ABCGHIMNO |
| London (5010) | ABCJKLMNO |
First, create a Script Variable called Location-Limited Search String and add 5 tokens:
- From the Script Level, click Variables to expand the property panel, then click Add
- In the Add Script Variables dialog, enter the Script Variable name and click Add
- Leave Type as Static text, enter ABC in the Parameters Value: field, and leave the Location ID: field blank, then click OK
- Click Add again, leave as Static text, enter Value: DEF, enter Location ID: 42, then click OK
- Click Add, leave as Static text, enter Value: GHI, enter Location ID: 70, then click OK
- Click Add, leave as Static text, enter Value: JKL, enter Location ID: 5010, then click OK
- Click Add , leave as Static text, enter Value: MNO, leave Location ID: blank, then click OK
The Add Script Variable dialog will look like:
Note the icon to the left of each token. The Location Limited token icons have a red "flag" indicator.
- Click OK to add the variable. The script sidebar will contain the new script-level variable Location-Limited Search String.
The next step is to set the
Event Input to use the script variable.
- Click on the Input HTML Element event in the Scripts section of the sidebar
- In the script Properties tab, click Event Input to expand the property panel
- Check the box next to use script variable
- Select Location-Limited Search String from the dropdown and click Apply
The sidebar will appear as:
The script will produce different searches using the different search strings based on the monitoring location. We can simulate running from different locations by modifying a configuration option:
- Click on the Configure Options button
and select DejaClick Options
- Click on the Replay Properties tab
- Change the Display Level to Advanced
- Click Variable Options to expand the property panel
- In the Default Location ID box, enter the desired Location ID ( 42 for LA, 70 for NY, 5010 for London)
- Click OK to save
The DéjàClick Options dialog will look like this:
After changing the Default Location ID to
42, replay the script to produce:
Change the Default Location ID to
70, and the replay will display:
Change the Default Location ID to
5010, and the replay will show:
Additional Information
Reusability
Script variables and datasets, once created, may be reused in different parts of the recording by assigning them to additional input values or keywords. For example, here is a list of several script variables that were created:
Say you want to use a different set of variables for the HTML input in Example 2, for instance, changing from animal names and attributes to celebrity names and types. Simply click on the two
Input HTML Element lines in Action 3 and select the new variables from the drop-down list, as follows:

The result of the next 3 replays will display:
Replay 1:
Replay 2:
Replay 3:
Imported vs. External Datasets
There are two flavors of Datasets: Imported and External File. All external dataset files must be in the DéjàClick datasets subfolder. You'll need to copy any external datasets to this folder prior to replay. By default, the folder is located in your Firefox profile folder under the dejaclick directory, but may be changed via the
DéjàClick Options->Paths tab. The dataset is designated an external file if the Option "Import dataset into script" is deselected in the
Add Dataset dialog (see
Example 2 above).
Here is the Properties sidebar at the Script Level with a description of the two different dataset types:
In the above list of datasets, the “animals” dataset was imported directly into the script. Its referenced values will remain static and any changes to the original source file will not affect subsequent script replays. Conversely, the “celebrities” dataset references an external file. Thus, if the file is ever modified, any referenced values that are updated will use the new values during subsequent script replays.
Back to Top