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. You define the iteration settings, see the General > Run Logic view in the Runtime settings. For details, see Run logic view.

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.

Run Logic block

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 Run logic view.

Back to top

Header files

Header files commonly contain forward declarations of classes, subroutines, variables, and other identifiers. The header files are stored under the installation in the include folder. In most cases, the name of the header file corresponds to the prefix of the protocol. For example, Web - HTTP/HTML functions that begin with an web prefix, are listed in the as_web.h file.

The following table lists the header files associated with several popular protocols:

Protocol
File
Citrix ICA
ctrxfuncs.h
Oracle NCA
orafuncs.h
SAP GUI
as_sapgui.h
Web (HTML\HTTP)
as_web.h
Web Services
wssoap.h
Windows Sockets
lrs.h

Back to top