Vuser script sections

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 will insert 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.

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 (manual) 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 of a Vuser script are not repeated when you run multiple iterations.

When you run scripts with multiple actions, you can indicate how to execute the actions, and how the Vuser executes them:

In the following example, Block0 performs a deposit, Block1 performs a transfer, and Block2 submits a balance request. The Login and Logout actions are common to the three blocks.

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.

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.

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