Lesson 2: Preparing Your Script for Replay

After you create a Vuser script, you validate it by running it from VuGen. Sometimes a replay will fail, even though the same actions succeeded during the recording.

Many applications use dynamic values that change each time you use the application. For example, some servers assign a unique session ID for every new session. When you try to replay a recorded session, the application creates a new session ID that differs from the recorded session ID. Dynamic values, such as these unique session IDs, may pose difficulties when you replay specific types of Vuser scripts. For example, dynamic session IDs often pose problems when replaying Web-HTTP/HTML scripts, but not when replaying TruClient scripts.

LoadRunner uses correlations to address the issue of dynamic values. When you correlate a value, VuGen saves the changing values, in our case the session ID, to a parameter. When running the Vuser script, the Vuser does not use the recorded value—instead, it uses the new session ID, assigned to it by the server.

For scripts that contain dynamic parameters, such as session IDs, VuGen automatically prompts you at the end of the recording to correlate the values. In the previous lesson, we bypassed the correlations, in order to view the script as is.

In this lesson you will learn how to correlate the dynamic values, and facilitate a successful replay.

How do I correlate my script?

If you try to replay the unmodified Vuser script that you recorded in Lesson 1: Building a Vuser Script, the replay will fail. The new session ID will not match the recorded ID, and this will cause a failure.

To overcome this issue, you use VuGen's Design Studio to correlate the session ID. Normally, VuGen scans the script at the end of the recording session and prompts you with the suggested correlations.

However, you can open the Design Studio at any time to scan the script for correlations. You can also undo any correlation that you did via the Design Studio.

  1. Open the Design Studio.

    Click the toolbar's Design Studio button, or select Design > Design Studio.

    VuGen scans the script and its associated data, searching for possible dynamic values.

  2. Correlate the Session ID.
    1. Select the Session ID entry in the Correlation tab, and click Correlate. VuGen changes the status of the Session ID to Applied, and inserts a new function at the top of the Vuser script. The new function saves the original session ID to a parameter.

    2. Close the Design Studio.
  3. Examine the syntax of the correlation statement.

    In the VuGen editor, locate the function that VuGen added to the beginning of the script. The new entry has the following format:

    "RegExp=userSession\\ value=(.*?)>\\n<table\\ border",

    The web_reg_save_param_regexp function instructs VuGen to save the first occurrence of the value contained in the regular expression (the unique session ID) to a parameter called userSession.

Back to top

Next steps: