Lesson 3: Replaying Your Vuser Script
In the previous lessons, you recorded a set of typical user actions, and prepared the script for replay.
Before replaying the script, you can configure the runtime settings for the script, which define the behavior of the Vuser.
In this lesson you will cover the following topics:
- How do I set the runtime behavior?
- How do I run my Vuser script?
- Where can I view information about the replay?
- How do I know if my script replayed successfully?
- How do I search or filter the results?
LoadRunner runtime settings let you emulate different kinds of user activity and behavior. For example, you could emulate a user who responds immediately to output from the server, or a user who stops and thinks before each response. You can also configure runtime settings to specify how many times the Vuser should repeat a set of actions in the Vuser script.
There are general runtime settings, and settings that are specific to certain Vuser protocols only. For example, for a Web emulation, you could instruct your Vusers to replay your script in Firefox, Chrome, or Internet Explorer. Runtime settings for specific protocols will be covered in Lesson 4: Preparing a Vuser Script for Load Testing. This lesson describes some of the general runtime settings—settings that apply to all Vuser protocols. The General runtime settings include:
- Run Logic. The number of times that a Vuser repeats various sections of the Vuser script.
- Pacing. The time to wait between repetitions.
- Think Time. The time the Vuser stops to think between steps in the script.
- Log. The level of information that you want to gather during playback.
Note: This lesson describes how to use VuGen to modify the runtime settings. A later lesson describes how to use the LoadRunner Controller to modify the runtime settings.
- Open the Vuser script that you saved in the previous lesson.
Open the Runtime Settings view.
Click Replay > Runtime Settings or press F4. The Runtime Settings view opens in the VuGen editor.
Set the Run Logic settings.
In the left pane, under General, click Run Logic.
The Run Logic settings enable you to set the number of iterations for the Vuser script. This is the number of times to repeat the Action section of the Vuser script when the script is replayed.
Set the Number of iterations to 2.
Set the Pacing settings.
In the left pane, under General, click Pacing.
The Pacing settings enable you to control the time between iterations. You will specify a random time. This accurately emulates a real-life setting where the user waits between actions, but at random intervals. For example, you do not see real users always waiting exactly 60 seconds between repeated actions.
Select the third radio button, and select the following:
Start new iteration at Random intervals, every 60.000 to 90.000 second(s).
Set the Log settings.
In the left pane, under General, select Log.
The Log settings indicate how much information to log while running the Vuser Script. While developing a Vuser script, you may want to enable some logging for debugging purposes, but once you verify that your script is functional, you can enable logging for errors only, or even disable logging.
Select Extended log and enable Parameter substitution. This option will be relevant for the following lesson at which point it will be discussed.
View the Think Time settings.
In the left pane, under General, click Think Time.
Keep the default think time setting - Ignore think time. You will set the think time from the Controller. Keep in mind that when you run the script in VuGen, it will run quickly since it will not include think time.
After recording the Vuser script and setting the runtime settings, you are ready to run the script.
To run a Vuser script:
- Open the Vuser script in VuGen.
Click Replay > Run or click the Replay button on the VuGen toolbar.
VuGen provides a number of indicators that your script is running.
- The message "Running" appears in the lower left corner of VuGen.
- A yellow marker appears in the Editor and indicates the specific line that is being replayed.
- The Step Navigator pane indicates the step that is being replayed.
The Output pane displays messages as the replay progresses.
When the Vuser script stops running, you can view a summary of the replay.
A general summary with links to other reports, opens in the <Script Name> : Replay Summary tab.
This tab lists basic information about the script run, such as the duration of the replay, and the start and end times of the replay. In addition, the Replay Summary tab provides you with a link that displays a log of the script events, and another link that displays detailed results of the script run.
The Output pane shows the replay log, a list of the events that occurred during the replay of the script. The log uses color-coding to display a textual summary of the events that occurred during the replay.
In this section of the tutorial, you will open the Output pane and locate specific events and notifications within the log.
To view the Replay log:
- After replaying the script, the Output pane usually opens. If it is not open, click View > Output or click the Output button on the VuGen toolbar.
Make sure that Replay is selected in the Output pane.
- From the VuGen menus, click Search > Quick Find to open the Search dialog box.
- From Scope, select Current Script.
- Click Include in search, and then select the Logs check box.
- Locate the following items in the Replay log, by entering the following text into the Find text field:
"Virtual User Script Started" - the beginning of the script run.
- "Vuser Terminated" - the end of the script run.
"iteration" - the beginning and the end of each iteration and the iteration number. (This text appears in orange lettering.)
Note: The Output pane displays successful steps in green and errors in red. For example, if the Vuser was unable to connect to the server, the Output pane would display the error text in red, and indicate the line number in the script where the error occurred.
Tip: If you double-click a line in the Output pane, VuGen shows the corresponding step in the VuGen script editor.
After you replay the events that you recorded, you need to look at the replay results to see if the script replayed successfully. If something failed, you want to know when and why it failed.
In this section you will view and analyze the results of your script run. VuGen summarizes the results of the replay in the Test Results window.
When the Test Results window first opens, it contains two panes: The Tree pane (on the left) and the Results Summary pane (on the right).
- The Tree pane contains the results tree. Each iteration in the tree is numbered.
- The Results Summary pane contains the details of the script replay, as well as screen recorder movies, if any. The top table indicates which iterations passed and which failed. The test is considered to have passed when the Vuser successfully navigates through the HP Web Tours site according to the original recording. The bottom table indicates whether transactions and checkpoints passed or failed. You will add these features to your test later on in the tutorial.
To view replay results:
- Click the Replay Summary tab.
- Click the Test Results link. The Test Results window opens and displays a summary of the replay results.
In the next section, you will drill down into the replay results to determine if the script reached the intended Web pages during replay.
If your replay results indicate that something failed, you can drill down and locate the point of failure.
In the left Tree pane of the Test Results window, you can expand the test tree and view the results of each step separately. The right Summary pane shows a snapshot of the replay during that iteration.
- Expand an iteration node in the tree.
- In the results tree, expand the parent basic_tutorial Iteration 1 node.
- Expand the Action Summary node. The expanded node shows a list of the steps performed in that iteration.
View a result snapshot.
Click the Submit Data:login.pl node. The Summary pane displays the replay snapshot associated with that step.
Analyze the summary.
The right pane displays the summary for the selected step: the object or step name, the details about whether the page loaded successfully, the result (Passed, Failed, Done, or Warning), and the time the step was performed.
Search for a result status.
You can search the replay results for the words Passed or Failed.
This is helpful, as in a case where the overall Results Summary indicates that the replay failed, you can determine where it failed.
To search the replay results, select Tools > Find or click the Find button on the Test Results toolbar. The Find dialog box opens.
Select the Passed check box, make sure no other options are selected, and click Find Next. The Test Tree pane highlights the first step in which the status is Passed.
Note: If no steps of the selected status can be found, no step is highlighted.
Filter the results.
You can filter the Test Tree pane to display a specific iteration or status. For example, you can filter it to show only Failed status.
Close the Test Results window.
Click File > Exit.
Where to go from here
You have successfully replayed your Vuser script that emulates a user operating the HP Web Tours application. You can now proceed to Lesson 4: Preparing a Vuser Script for Load Testing.