Last modified on December 4, 2017
Note: To use this guide, you need to know how to use AlertSite DéjàClick transaction recording tool. If you do not have the DéjàClick toolbar in your Firefox browser, go to the DéjàClick Downloads page to download the DéjàClick add-on and additional modules (TrueScreen and ImageMagick). If 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 will 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 accessed for the Properties Sidebar at the Script level. 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 when replaying on the local desktop. Other field separator characters may also be used in the dataset file.

Note: DéjàClick version 1.3.0.0 or greater is required to use script variables.

To make our examples simple, we will use www.google.com.

Record a Transaction

First, record a transaction with DéjàClick. Click Begin recording to power on DéjàClick and start recording.

Click in the Google search bar, enter some text and click Google Search. We will use name@domain.com for the initial search. When the search completes, click Stop_recording.png to stop recording, and then OK in the confirmation dialog. This records a script containing 2 actions and 2 events.

Click Replay all to replay the recording.

Open the Script Results sidebar by Results Sidebar on the DéjàClick toolbar.

The sidebar has 2 parts:

  1. DéjàClick step tree at the top.

  2. The Results tab and Properties tab at the bottom.

Sidebar

There are 2 ways to add a script variable:

  1. Create it at the Script level.

  2. Create it or add it at the Event level on the Input event.

Several steps are required to set up a script variable. Once you know what variables you want to use in your recording, it is a simple process.

Create a Script Variable

To illustrate how to create a script variable, we will outline the steps for using a random email address in the Google search bar.

Click the Properties tab in the DéjàClick sidebar and click on the top-level Script name in the tree view at the top.

The sidebar will present the list of properties at the Script level:

Script level properties

Click Variables to open the Script Variables property panel:

Variables property panel

Using this panel, we will construct the script variable from a series of tokens. Click the Add button to display the Add Script Variable dialog:

Add Script Variable dialog

Enter a name for the script variable - for our example, Random Email Address, then click the Add... button to display the Add Token dialog box:

Add token

The Add Token dialog's Type drop-down list contains:

  • Static Text
  • Random Text
  • Random Number
  • Auto Increment
  • Relative Date/Time
  • Dataset Value
  • Replay Location

Note that the Parameters section changes depending on the Type.

We want to create the random email address script variable using 3 tokens:

  • A 4-character random text string.

  • A 3-digit random number.

  • The static string @mydomain.com.

Fill in the Add Token dialog as follows:

  1. Select Type: Random text.

  2. Enter minimum length 4 characters.

  3. Enter maximum length of 4 characters.

  4. Leave the Location ID blank and click OK.

Add the next token, the 3-digit random number. Click Add... and fill in the Add Token dialog as follows:

  1. Select Type: Random number.

  2. Enter minimum value 0.

  3. Enter maximum value 999.

  4. Leave Location ID blank and click OK.

Create the third and final token, a static string @mydomain.com. Click Add... to and fill in the Add Token dialog as follows:

  1. Select Type: Static text.

  2. Enter @mydomain.com in the Value field.

  3. Leave Location ID blank and click OK.

Click OK to save. The Add Script Variable dialog box will now contain:

All 3 tokens

Click the Preview... button to display a sample of what the variable will look like during replay, for example:

Preview

Click OK to close the preview box, then click OK to complete the script variable construction. The Variables panel will now contain the Random Email Address script variable.

You can now select this script variable in the Event Input panel for the Input HTML Element event, which is the search field text:

Select Event Input

You can also add a Script Variable directly in the Event Input panel of an Input HTML Element event by clicking the icon to the right of the Select... field:

Create from Event

By using the script variable in place of the original search term, each replay will produce a search for a different email address:

Replay 1:

Search 1

Click the image to enlarge it.

Replay 2:

Search 2

Click the image to enlarge it.

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.

Additional Examples

Below are more examples for using script variables:

Script Variable as a Keyword

Location-Limited Tokens

Dataset Script Variables

Additional Information

Reusability

Imported vs. External Datasets