Vuser script sections

This topic describes the sections in a Vuser script.

Script sections overview

Each Vuser script contains at least the following sections:

Script Section Used when recording... Is executed when...
vuser_init
a login to a server
the Vuser is initialized (loaded)
Actions
client activity
the Vuser is in Running status
vuser_end
a logoff procedure
the Vuser finishes or is stopped

Before and during recording, you can select the section of the script into which VuGen inserts the recorded functions.

When you run multiple iterations of a Vuser script, only the Actions sections of the script are repeated—the vuser_init and vuser_end sections are not repeated. For more information on the iteration settings, see the General > Run Logic view in the Runtime settings.

Back to top

VuGen script editor

You use the VuGen script editor to display and edit the contents of each of the script sections. You can display the contents of only a single section at a time. To display a section in the script editor, double-click the name of the section in the Solution Explorer.

Back to top

Java classes

When working with Vuser scripts that use Java classes, you place all your code in the Actions class. The Actions class contains the following methods: init, action, and end. These methods correspond to the sections of scripts developed using other protocols—you insert initialization routines into the init method, client actions into the action method, and log off procedures in the end method.

public class Actions{
    public int init() {
        return 0;}
    public int action() {
        return 0;}
    public int end() {    
        return 0;}
}

For more details, see Java Vuser protocol.

Back to top

Script section structure example

Every Vuser script contains three sections: vuser_init, run (actions), and vuser_end. You can instruct a Vuser to repeat the Run section when you run the script. Each repetition is known as an iteration.

The vuser_init and vuser_end sections are not repeated when you run multiple iterations.

When you run scripts with multiple actions, you can indicate how the Vuser executes the actions.

You can create multiple blocks containing initialization (vuser_init), action, and finalization (vuser_end) sections. You can also add multiple action sections to each block.

In the following example, you could set Block1 to perform a deposit and Block2 to submit a balance request. This process can be repeated multiple times.

Sequence. You can set the order of actions within your script. You can also indicate whether to perform actions sequentially or randomly.

Iterations. In addition to setting the number of iterations for the entire Run section, you can set iterations for individual actions or action blocks. This is useful, for example, in emulating a commercial site where you perform many queries to locate a product, but only one purchase.

Weighting. For action blocks running their actions randomly, you can set the weight or percentage of each action within a block.

For details on creating blocks and adding actions, see Configure runtime settings.

Back to top

Header files

Header files commonly contain forward declarations of classes, subroutines, variables, and other identifiers. In most cases, the name of the header file corresponds to the prefix of the protocol. For example, Database functions that begin with an lrd prefix, are listed in the lrd.h file.

The following table lists the header files associated with the most commonly used protocols:

Protocol
File
Ajax (Click & Script)
web_ajax.h
Citrix
ctrxfuncs.h
COM/DCOM
lrc.h
Database
lrd.h
FTP
mic_ftp.h
General C function
lrun.h
IMAP
mic_imap.h
LDAP
mic_mldap.h
MAPI
mic_mapi.h
Oracle NCA
orafuncs.h
POP3
mic_pop3.h
RDP
lrrdp.h
SAP GUI
as_sapgui.h
Siebel
lrdsiebel.h
SMTP
mic_smtp.h
Terminal Emulator
lrrte.h
Web (HTML\HTTP)
as_web.h
Web (Click & Script)
web_api.h
Web Services
wssoap.h
Windows Sockets
lrs.h

Back to top