You are on page 1of 17

Developing Vuser Scripts

Krish Hegde 1
Developing Vuser Scripts
• The structure and content of a Vuser script
differ from one Vuser type to another.
• For example, Database Vuser scripts
always have three sections, are written in
a code that resembles C, and include SQL
calls to a database server.
• In contrast, GUI Vuser scripts have only
one section, and are written in TSL (test
script language).
Krish Hegde 2
Developing Vuser Scripts

1. You begin the process of developing a Vuser script by

recording a basic script.
2. You enhance the basic script by adding control-flow
structures, and by inserting transactions and
rendezvous points into the script.
3. You then configure the run-time settings. The run-time
settings include iteration, log, and timing information,
and define how the Vuser will behave when it executes
the Vuser script.
4. To verify that the script runs correctly, you run it in
stand-alone mode.
5. When your script runs correctly, you incorporate it into a
LoadRunner scenario.
Krish Hegde 3
• The Vuser Script Generator, also known as
VuGen, enables you to develop Vuser scripts for
a variety of application types and communication
• VuGen not only records Vuser scripts, but also
runs them. Running scripts from VuGen is useful
when debugging. It enables you to emulate how
a Vuser script will run when executed as part of
a scenario.

Krish Hegde 4
Recording Vuser Scripts
• When you record a Vuser script, VuGen
generates various functions that define the
actions that you perform during the recording
session. VuGen inserts these functions into the
VuGen editor to create a basic Vuser script.
• You use VuGen to develop a Vuser script by
recording a user performing typical business
processes on a client application. VuGen
creates the script by recording the activity
between the client and the server.
Krish Hegde 5
Recording Vuser Scripts

Krish Hegde 6
Recording Vuser Scripts
• When you record a Vuser script, VuGen
generates Vuser functions and inserts them into
the script. There are two types of Vuser
– General Vuser Functions:
The general Vuser functions are also called LR
functions because each LR function has an lr prefix.
– Protocol-Specific Vuser Functions:
The protocol-specific functions are particular to the type
of Vuser that you are recording. For example, VuGen
inserts LRD functions into a database script, LRT
functions into a TUXEDO script and LRS functions
into a Windows Socket script.
Krish Hegde 7
Transaction & Rendezvous
• lr_start_transaction: Marks the
beginning of a transaction.
• lr_end_transaction: Marks the end of a
• lr_rendezvous: Sets a rendezvous point.

Krish Hegde 8
Recording Vuser Scripts
• Each Vuser script that you create contains at
least three sections: vuser_init, one or more
Actions, and vuser_end.
• During recording, you can select the section of
the script into which VuGen will insert the
recorded functions.
• In general, you record a login to a server into the
vuser_init section, client activity into the Actions
sections, and the logoff procedure into the
vuser_end section.

Krish Hegde 9
Recording Vuser Scripts

Krish Hegde 10
Recording Vuser Scripts

Krish Hegde 11
DB Vuser scripts

Krish Hegde 12
Recording Web Vuser
• Step 1: File > New> eBusiness (http/html)
• Step 2: Click on Record button
• Step 3: Enter URL and press OK
• Step 4: The web pages opens, start
browsing the web page and perform
• Step 5: Stop recording
• Step 6: Run to debug the script.
Krish Hegde 13
Insert Transaction Points
• Step 7: Insert Transaction Start and
Transaction end points
• Step 8: Insert Rendezvous point
• Step 9: Run to debug script.
• Step 10: Insert Comments for reference.

Krish Hegde 14
Using C Functions
• VuGen generates Vuser scripts in C. All
standard ANSI C conventions apply to the
scripts, including control flow and syntax.
• You can add comments and conditional
statements to the script just as you do in other C
programs. You declare and define variables
using ANSI C conventions.
• There are many limitations for adding functions
in Vuser Script.
• Many C functions are not supported by Vuser
Krish Hegde 15
Using C Functions
• However, since the interpreter that is used
to run Vuser scripts does not support any
Microsoft extensions to ANSI C, you
cannot use Microsoft’s include files.
• It is better to use VuGen for recording
Vuser Scripts compared to manual coding
in C as there are many limitations in
adding functions.

Krish Hegde 16
• Questions?

Krish Hegde 17