Introduction to VuGen (Virtual User Generator) Script with Recording Example

Introduction to VuGen Script: Learn the first component of LoadRunner with recording and creating a basic VuGen script

In this Hands-On LoadRunner Training Series, a brief Introduction on LoadRunner was given in our previous tutorial.

In this tutorial, we will start with ‘VuGen’ (Virtual User Generator) which is the first component of the LoadRunner tool. It is used to capture the network traffic (or requests) and create scripts that emulate the real user actions on a web Application (or a Desktop application).

=> Click Here For Complete Series of LoadRunner Tutorials

introduction to vugen scripts (1)

How does a Web Application Work?

Before starting with VuGen, let us first understand how a Web Application works.

Web applications are hosted on Servers and can be accessed via the internet through a client (browser for example). The client sends a request and the server processes the request and sends the response back (request/response is often referred to as network traffic).

The client and the server clearly understand each other’s language because they follow a standard ‘set of rules’ for communication which is called the ‘protocol’. There are many types of protocols but the most commonly used one on the web is the ‘hyper-text transfer protocol’ or the ‘http’ which almost all of us are aware of.

Other examples of commonly used protocols are https, FTP, SAP Web protocol, Oracle NCA protocol etc.

On a high-level, these are the sequence of events that take place when a user performs the actions on a Web Application:

  • The user types the URL on the client/browser (Example:
  • Browser/Client parses the URL to find the protocol, host, port etc.
  • Browser/Client then forms an HTTP request.
  • The host is translated to the IP address (DNS lookup).
  • The socket is opened from the user computer to that IP address on the specified port (usually 80).
  • A connection is made, and the HTTP request is sent to the host.
  • Server inspects the request, does the necessary processing and sends the response back (usually an HTML page).
  • Browser/Client receives the response and parses the HTML.
  • The user sees the page on the screen.

1.Request and responses

The request that we are talking about is an HTTP request in most cases. HTTP request has a ‘header’, a ‘body’ and has one of these as the method – GET, POST, DELETE etc. GET and POST is the most common methods.

Without going deep into the understanding of these methods, let us simply remember that:

GET method is used to retrieve the information from the server.

And POST method is used to send data to the server.

Now, let us take an Example of application and see how the HTTP request actually looks like.

In this Example, we are registering a user on the application.

2. registering a user on the application

The corresponding HTTP requests for this user action can be seen in the developer tools (F12) page of the browser (we have used Internet Explorer here).

Shown below (marked in red) is the HTTP request for ‘Registering User’ action on As we see, among the other fields, the protocol is ‘HTTPS’ and the method is ‘POST’.

3.http request for ‘Registering User’ action on

If we go to the Details, we can see the Request header and body (highlighted in red).

4.Request header

5.Request body

Now let’s go back to VuGen.

VuGen captures the HTTP traffic when we perform actions on an application and converts the same into a script (which when replayed emulates the real user actions on the application).

Here is how the script looks like (on the VuGen tool) for user registration user action that we just discussed. As we see, the script is nothing but the HTTP request(s) which is put in the form of functions (two functions here include – web_add_cookie and web_custom_request). We will discuss functions in detail in our subsequent tutorials.

6.VuGen scripts

Here, it is important to note that VuGen scripts (when re-played) do not emulate the actual user actions on the browser, but emulate the requests (network traffic) that get generated as a result of the user actions.

So, VuGen doesn’t work at the GUI level (like the functional test tools do – like UFT/QTP) but works at the network level (HTTP requests).

Now let’s see how to actually record and create scripts in VuGen.

For this, we will use the sample ‘Web Tours’ application that comes with the Load Runner tool.

The url of this application is (this application will be hosted on our local machine) and we have to start the Web Tours Apache server (that also comes with the LoadRunner tool) to be able to use this application (we can also download the Web Tours application/server from Micro Focus website).

The below figure shows the file that is used to start the server and the corresponding command prompt window for the Apache server.

7.file used to start the server and the corresponding command prompt window for the Apache server

8.web tours

Let’s start recording the user actions on this application with VuGen.

Double-click on the VuGen shortcut

9.Virtual user Generator

VuGen is getting initialized… (we are using Load Runner 12.55 here)

10.HPE Virtual User Generator

The main page in VuGen where we can see the recent scripts, useful links, and other options is opened.

10.HPE Virtual User Generator

In order to record a new application, open File => New Script, and Solution

12.To record a new application

Next, VuGen allows us to select the protocol (or protocols) that are used for client-server communication in our application (Web Tours in this example). We have to know the protocol or protocols (some applications use multiple protocols) in advance. We will discuss the ways of finding this out in our subsequent tutorials.

Let’s select Single Protocol (Web-http/HTML) and enter the Script name and path. Single Protocol and enter the Script name and path.

As we can see, the VuGen screen has ‘Solution Explorer’ pane on the left. This is where all the assets of our script ‘Web Tours’ will be listed (we can have multiple scripts under a solution but here we have only one).

We have three defaults Actions – vuser_init, Action, and vuser_end. The script is actually recorded/written into these actions (for now this is an empty script as we have not recorded/written anything into the actions yet).

VuGen opens with three defaults Actions – vuser_init, Action, and vuser_end. The script is actually recorded/written into these actions (for now this is an empty script as we have not recorded/written anything into the actions yet)

14.VuGen opens with three defaults Actions

Let’s understand actions in detail:

Action: An action is a group of requests that perform a specific task. It is like a ‘function’ in a programming language.

Every Vuser script has three actions by default:

  1. vuser_init (records login to a server)
  2. Action (records user activity)
  3. vuser_end (records logoff procedure)

Apart from the default actions, we can create our own actions in the script.

For Example, for an e-commerce site, we can have the following actions:

  1. vuser_init (login into the application can be kept here)
  2. RegisterUser
  3. SearchProductAndOrder
  4. CancelOrder
  5. vuser_end (logout can be kept here)

When the script is run for multiple iterations, the vuser_init and the vuser_end actions are run only once and all the other actions are run multiple times (we will see this in detail when we discuss ‘Run-time Settings’).

Now let us start recording. Click on the Record button (red dot) or use the shortcut Ctrl+R.

15.Click on the Record button to start recording

VuGen allows us to select the following options:

#1) Record into action: Action into which the script is to be recorded. We can select one from the drop-down.

16.Record into action

#2) Record: What to record is to be selected from the dropdown list.

17.web browser

3. Application: The Application used for recording is to be selected from the drop-down menu or is to be opened by selecting the path.

4. URL address: URL address if in case we are recording a Web Browser.

5. Start recording: Option to start recording immediately or after some delay.

6. Working directory: The working directory.

19.Recording Options

Also, on the left bottom corner, we have the most important option for script recording – ‘Recording Options’ (highlighted in red above). We will see this in detail in two parts – Part1 (in the next tutorial) and Part2 (in the subsequent tutorials when we will also see ‘Correlation’).

So let’s park the ‘Recording Options’ for now and continue with recording. When we click on Start Recording button, the Web Tours Application will be launched in internet explorer.

Also, we can see a floating window recording bar (highlighted in red) that gives information and allows various controls on a recording.

20.floating window recording bar

Here is the description of various options which the floating recording window bar offers.

21.description of the various options that the floating recording window bar

A number of events are recorded to give the information on the events (HTTP traffic) that are currently recorded as we perform actions on the application/browser.

We will talk about Rendezvous, Comment and Text check in our subsequent tutorials. Other options are self-explanatory.

Let us continue with recording…

Enter the Username & Password and login (‘jojo’ user is registered by default with password ‘bean’, and we can register a new user if we want using the ‘sign up now’ link). 22.Enter Username and Password and login

Click on the ‘Flights’ button.

23.Click on ‘Flights’ button

Enter/select the details and continue.

24.Enter details and continue

Select flight and continue.

25.Select flight and continue

Enter the payment details and continue.

26.Enter the payment details and continue

‘Sign Off’ now

27.Sign off

28.After signoff

Now, we have completed recording the user actions on the Web Tours application, click on the ‘Stop Recording’ option on the Floating Recording bar. Note that while we were recording the user actions, VuGen was only capturing the events (HTTP traffic) but was not creating the script yet. on the ‘Stop Recording’

So after we stop recording, VuGen generates the script.

30. VuGen generates the script

It also performs some postscript generation operations which we will discuss later. script generation operations

Finally, VuGen generates the script and presents a Recording Report as shown below.

32.Recording Report

And here is how that Script looks like.



Just to summarize, we discussed the following in this tutorial:

  1. Introduction to VuGen
  2. Basic understanding of Web Application, HTTP requests, and Protocols.
  3. Recording and creating a basic VuGen script (using http protocol) on Web Tours application.

In our upcoming tutorial, we will discuss more on Recording Options!!

=> Visit Here For Complete Series of LoadRunner Tutorials

PREV Tutorial | NEXT Tutorial