Script Variables

Last modified on July 26, 2024
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

  1. Click on the DéjàClick toolbar.

  2. Navigate to google.com.

  3. Enter [email protected] in the search bar and click Google Search.

  4. Click on the DéjàClick toolbar.

  5. Click OK in the confirmation dialog.

  6. Click to replay the recording.

  7. Switch to the Properties tab of the DéjàClick sidebar.

  8. Expand the Variables section and click Add.

    Tip: The Variables section is available only at the script level.
    Script variables

    Click the image to enlarge it.

  9. Enter Random email address in the Name field of the Add Script Variable dialog, and then click Add.

    Adding a script variable
  10. 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.

    Adding the first token
  11. Click Add in the Add Script Variable dialog.

  12. 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.

    Adding the second token
  13. Click Add in the Add Script Variable dialog.

  14. Create the third token:

    • Select Static text from the Type drop-down list.

    • Enter @mydomain.com in the Value field.

    • Click OK.

    Adding the third token
  15. Click Preview in the Add Script Variable dialog to see a sample variable, then click OK to close the preview window.

    Variable preview

    Click the image to enlarge it.

  16. Click OK in the Add Script Variable dialog.

  17. Select the Change on <INPUT> Search event in the script tree.

  18. Expand the Event Input section of the Properties tab.

    The Event Input section

    Click the image to enlarge it.

  19. Clear the Replay using keystrokes check box.

  20. Select the Use script variable check box, select the created script variable from the drop-down list, and click Apply.

    Applying the script variable
  21. Click to replay the transaction with the script variable.

DéjàClick 1.x

  1. Click on the DéjàClick toolbar.

  2. Navigate to google.com.

  3. Enter [email protected] in the search bar and click Google Search.

  4. Click on the DéjàClick toolbar.

  5. Click OK in the confirmation dialog.

  6. Click to replay the recording.

  7. Switch to the Properties tab of the DéjàClick sidebar.

  8. Expand the Variables section and click Add.

    Tip: The Variables section is available only at the script level.
    Script variables

    Click the image to enlarge it.

  9. Enter Random email address in the Name field of the Add Script Variable dialog, and then click Add.

    Adding a script variable
  10. 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.

    Adding the first token
  11. Click Add in the Add Script Variable dialog.

  12. 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.

    Adding the second token
  13. Click Add in the Add Script Variable dialog.

  14. Create the third token:

    • Select Static text from the Type drop-down list.

    • Enter @mydomain.com in the Value field.

    • Click OK.

    Adding the third token
  15. Click Preview in the Add Script Variable dialog to see a sample variable, then click OK to close the preview window.

    Variable preview

    Click the image to enlarge it.

  16. Click OK in the Add Script Variable dialog.

  17. Select the Change on <INPUT> Search event in the script tree.

  18. Expand the Event Input section of the Properties tab.

    The Event Input section

    Click the image to enlarge it.

  19. Clear the Replay using keystrokes check box.

  20. Select the Use script variable check box, select the created script variable from the drop-down list, and click Apply.

    Applying the script variable
  21. Click to replay the transaction with the script variable.

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)

ABCDEFMNO

New York (70)

ABCGHIMNO

London (5010)

ABCJKLMNO

Let's create the script variable and add five tokens:

  1. Click the script name in the recorded transaction.

  2. Switch to the Properties tab of the DéjàClick sidebar.

  3. Expand the Variables section and click Add.

  4. Enter Location-limited search string in the Name field of the Add Script Variable dialog, and then click Add.

  5. 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.

  6. Click OK in the Add Script Variable dialog.

    DéjàClick 2.0

    The created variable with tokens

    DéjàClick 1.x

    The created variable with tokens
  7. Select the Change on <INPUT> Search event in the script tree.

  8. Expand the Event Input section of the Properties tab.

    DéjàClick 2.0

    Event Input

    DéjàClick 1.x

    Event Input
  9. Clear the Replay using keystrokes check box.

  10. Select the Use script variable check box.

  11. 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

    Applying the script variable

    DéjàClick 1.x

    Applying the script variable
  12. In DéjàClick 2.0, select  > Options.

    In DéjàClick 1.x,  > DéjàClick Options.

  13. Switch to the Replay tab.

  14. 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

    Variable Options

    DéjàClick 1.x

    Variable Options

After changing the default location to 42, the script replay will produce the following:

Replay results with the script variable

Click the image to enlarge it.

See Also

Simulate New User
Configuring Scripts

Highlight search results