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. |
About script variables
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:
-
Log in 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.
You can access script variables from 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
-
Replay location
-
JavaScript code
Note: | DéjàClick v. 1.3.0.0 or greater is required to use script variables. |
Tutorial
This tutorial illustrates how to create and use script variables in transactions. We will outline the steps for using a random email address in the Google search bar. The email address will be a script variable created by concatenating three tokens: a 4-character token, 3-digit token, and @mydomain.com static string. The email address will change every time the recording is replayed.
DéjàClick 2.0
-
Click on the DéjàClick toolbar.
-
Navigate to google.com.
-
Enter [email protected] in the search bar and click Google Search.
-
Click on the DéjàClick toolbar.
-
Click OK in the confirmation dialog.
-
Click to replay the recording.
-
Switch to the Properties tab of the DéjàClick sidebar.
-
Expand the Variables section and click Add.
Tip: The Variables section is available only at the script level. -
Enter Random email address in the Name field of the Add Script Variable dialog, and then click Add.
-
Create the first token:
-
Select Random text from the Type drop-down list.
-
Set Min length to 4.
-
Set Max length to 4.
-
Click OK.
-
-
Click Add in the Add Script Variable dialog.
-
Create the second token:
-
Select Random number from the Type drop-down list.
-
Set Min value to 0.
-
Set Max value to 999.
-
Click OK.
-
-
Click Add in the Add Script Variable dialog.
-
Create the third token:
-
Select Static text from the Type drop-down list.
-
Enter @mydomain.com in the Value field.
-
Click OK.
-
-
Click Preview in the Add Script Variable dialog to see a sample variable, then click OK to close the preview window.
-
Click OK in the Add Script Variable dialog.
-
Select the Change on <INPUT> Search event in the script tree.
-
Expand the Event Input section of the Properties tab.
-
Clear the Replay using keystrokes check box.
-
Select the Use script variable check box, select the created script variable from the drop-down list, and click Apply.
-
Click to replay the transaction with the script variable.
DéjàClick 1.x
-
Click on the DéjàClick toolbar.
-
Navigate to google.com.
-
Enter [email protected] in the search bar and click Google Search.
-
Click on the DéjàClick toolbar.
-
Click OK in the confirmation dialog.
-
Click to replay the recording.
-
Switch to the Properties tab of the DéjàClick sidebar.
-
Expand the Variables section and click Add.
Tip: The Variables section is available only at the script level. -
Enter Random email address in the Name field of the Add Script Variable dialog, and then click Add.
-
Create the first token:
-
Select Random text from the Type drop-down list.
-
Set Min length to 4.
-
Set Max length to 4.
-
Click OK.
-
-
Click Add in the Add Script Variable dialog.
-
Create the second token:
-
Select Random number from the Type drop-down list.
-
Set Min value to 0.
-
Set Max value to 999.
-
Click OK.
-
-
Click Add in the Add Script Variable dialog.
-
Create the third token:
-
Select Static text from the Type drop-down list.
-
Enter @mydomain.com in the Value field.
-
Click OK.
-
-
Click Preview in the Add Script Variable dialog to see a sample variable, then click OK to close the preview window.
-
Click OK in the Add Script Variable dialog.
-
Select the Change on <INPUT> Search event in the script tree.
-
Expand the Event Input section of the Properties tab.
-
Clear the Replay using keystrokes check box.
-
Select the Use script variable check box, select the created script variable from the drop-down list, and click Apply.
-
Click to replay the transaction with the script variable.
More examples
Location-limited tokens
You can use a monitoring strategy to populate your web form with different strings when monitoring at different locations. In this example, we will use the Google Search script from the tutorial. We will construct a script variable with five static string tokens that are limited by three monitoring locations: Los Angeles (Location ID 42), New York (Location ID 70), and London (Location ID 5010). String DEF
will be limited to Los Angeles, GHI
– to New York, and JKL
– 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) |
|
New York (70) |
|
London (5010) |
|
Let's create the script variable and add five tokens:
-
Click the script name in the recorded transaction.
-
Switch to the Properties tab of the DéjàClick sidebar.
-
Expand the Variables section and click Add.
-
Enter Location-limited search string in the Name field of the Add Script Variable dialog, and then click Add.
-
Add five tokens of the Static string type with the following parameters:
Token Parameters Token 1
Value – Enter ABC.
Token 2
Value – Enter DEF.
Location ID – Enter 42.Token 3
Value – Enter GHI.
Location ID – Enter 70.Token 4
Value – Enter JKL.
Location ID – Enter 5010.Token 5
Value – Enter MNO.
-
Click OK in the Add Script Variable dialog.
DéjàClick 2.0
DéjàClick 1.x
-
Select the Change on <INPUT> Search event in the script tree.
-
Expand the Event Input section of the Properties tab.
DéjàClick 2.0
DéjàClick 1.x
-
Clear the Replay using keystrokes check box.
-
Select the Use script variable check box.
-
Select the Location-limited search string variable from the drop-down list and click Apply.
The script will produce searches using the different search strings based on the monitoring location.
DéjàClick 2.0
DéjàClick 1.x
-
In DéjàClick 2.0, select > Options.
In DéjàClick 1.x, > DéjàClick Options.
-
Switch to the Replay tab.
-
Expand the Variable Options section, enter the desired location (42 for Los Angeles, 70 for New York, 5010 for London), and click Apply.
This will set the default location for the replay.
DéjàClick 2.0
DéjàClick 1.x
After changing the default location to 42, the script replay will produce the following: