Archive for the ‘Scripting’ Category.

Removing Zero from the Date in VuGen LoadRunner


Enter start date and end date and date should not include zero before actual value of month and day.


Invalid date format: 04/27/2011

Valid date format: 4/27/2011


//variable declaration
char month[10], day[10], year[10], startDate[10], endDate[10];
int nonZeroDay, nonZeroMonth;

/*if you want to run script for multiple interactions then you have to nullify
the concatenated string before starting new iteration otherwise it
will keep the old value*/
strcpy(startDate, “”);
strcpy(endDate, “”);

//original date which contain zero in the date
lr_save_datetime(“Today’s Date is: %m/%d/%Y”, DATE_NOW, “normalDate”);

//for generating non zero start date

//to assign the current date parts to a parameter
lr_save_datetime(“%m”, DATE_NOW, “month”);
lr_save_datetime(“%d”, DATE_NOW, “day”);
lr_save_datetime(“%Y”, DATE_NOW, “year”);

//to remove zero from the string. e.g.getting ‘4’ from ’04’

nonZeroMonth = atoi(lr_eval_string(“{month}”));
lr_save_int(nonZeroMonth, “month”);

nonZeroDay = atoi(lr_eval_string(“{day}”));
lr_save_int(nonZeroDay, “day”);

//creating a date string using concatenation of nonzero date parts and separator ‘/’
strcat(startDate, lr_eval_string(“{month}”));
strcat(startDate, “/”);
strcat(startDate, lr_eval_string(“{day}”));
strcat(startDate, “/”);
strcat(startDate, lr_eval_string(“{year}”));

lr_save_string(startDate, “p_StartDate”);
lr_output_message(“Start Date is: %s”, lr_eval_string(“{p_StartDate}”));

//for generating non zero end date by incrementing date by one day offset
lr_save_datetime(“%m”, DATE_NOW + ONE_DAY, “month”);
lr_save_datetime(“%d”, DATE_NOW + ONE_DAY, “day”);

lr_save_datetime(“%Y”, DATE_NOW + ONE_DAY, “year”);
nonZeroMonth = atoi(lr_eval_string(“{month}”));
lr_save_int(nonZeroMonth, “month”);

nonZeroDay = atoi(lr_eval_string(“{day}”));
lr_save_int(nonZeroDay, “day”);

strcat(endDate, lr_eval_string(“{month}”));
strcat(endDate, “/”);
strcat(endDate, lr_eval_string(“{day}”));
strcat(endDate, “/”);
strcat(endDate, lr_eval_string(“{year}”));

lr_save_string(endDate, “p_endDate”);
lr_output_message(“End Date is: %s”, lr_eval_string(“{p_endDate}”));


Today’s Date is: 04/27/2011
Start Date is: 4/27/2011
End Date is: 4/28/2011

RTE protocol script recording in VuGen LoadRunner

Terminal Emulation (RTE):

Emulation of users who submit input to, and receive output from, character-based applications. VuGen LoadRunner has its own internal terminal emulator using which it connects to the application.

RTE Vuser:

  • RTE Vuser operates terminal emulator in order to load test client/server base applications.
  • Terminal emulator session is a collection of a real user’s actions.
  • RTE Vuser types character input into a terminal emulator, submits the data to a server, and then waits for the server to respond.
  • LoadRunner uses PowerTerm as a terminal emulator for emulating RTE session.
  • PowerTerm works like a standard terminal emulator, supporting common protocols such as IBM 3270 & 5250, VT100 and VT220.
  • VuGen records the terminal setup and connection procedure into the script.


    1. Click on New Script.
    2. Select Single Protocol Script and in All Protocols category choose Terminal Emulation (RTE).

    1. Click on Create for creating script and then click on Start Recording.
    2. PowerTerm Emulator will show up.
    3. Click on Communication menu and then click on Connect.

  1. In Connect window choose Terminal type: 3270 Display
  2. It will automatically set the default settings like Session Type, Terminal ID, and Port Number according to your Terminal Type value.
  3. You can change them according to your need.
  4. Enter Host Name, which is given in Test Plan.
  5. Click on Connect, it will connect to the server then follow the business flow given in test plan.
  6. When you are done with your business flow then stop recording.
  7. Now you can enhance your recorded script with transactions and synchronization functions.

Challenge 1: Finding blank row on Terminal screen to add user inputs

char text[100];

/* suppose top rows are reserved for function description and user can input data from 6th row onwards and total rows are 22 */

int row=6;

int flag=TRUE;

//Finding the blank row to add user inputs

while (flag){

//If it’s End of page then start from next page

if (row==22) {





TE_get_text_line(5,row,1, text);

if (strcmp(text,”_”)==0){







Challenge 2: Handling transaction status using Text Check on terminal screen




iReturn=TE_find_text (“RECORD(S) PROCESSED SUCCESSFULLY.”, 1,22,40,22, &col, &row, match);

lr_output_message(“value:%d”, iReturn);

if (iReturn==0){

lr_end_transaction(“T01_Modify_AccountDetails “,LR_PASS);


lr_end_transaction(“T01_Modify_AccountDetails “,LR_FAIL);


Creating Custom Request in VuGen LoadRunner

There are some situations where you need to create custom request so that you can manipulate the request according to your need. Here we will see how to create custom request and tamper with it to get our job done.


When we record the script for any web application, we generally choose HTML-based recording because it is easy and minimizes the correlations you have to handle in the script.

LoadRunner do generate custom request when some request does not fall under category of lr_web_submit_data() or lr_web_submit_form() requests category.


Suppose there is one request where you are sending some data items with it and every time there will be random number of data items like, first time there will be four data items second time there will be five data items in the same request. Here you cannot use same recorded request as number of data items are going to be different every time.

In below example you can see that there are only four data items in the request next time there may be five data item.

“Name=SearchResultsGrid_ctl04_ViewPackageDialogResult”, “Value=291570”, ENDITEM,
“Name=SearchResultsGrid_ctl08_ViewPackageDialogResult”, “Value=291566”, ENDITEM,
“Name=SearchResultsGrid_ctl11_ViewPackageDialogResult”, “Value=291563”, ENDITEM,
“Name=SearchResultsGrid_ctl12_ViewPackageDialogResult”, “Value=291562”, ENDITEM,


Here you can create a custom request and use a parameter which will hold the manipulated string of data items. In that string you can save different number of data items and you can change it as required.


    1. First record the script with HTML-based recording and with proper transaction names for every action.
    2. Save that script and then click on Tools> Regenerate Script…

    1. Below popup will come, click on Options…

    1. It will show you the Regenerate options, Click on General> Recoding

  1. There are two options available, HTML-based script and URL-based script. Choose URL-based script.
  2. For URL-based script there is a button for advanced settings named URL Advanced, click on it.
  3. From the new popup select Use web_custom_request only.
  4. Save the settings and regenerate the script.
  5. In the regenerated script you can see that new script is generated which contain only web_custom_request.
  6. Now find the particular request which you want to manipulate with the help of transaction names which you have given while recording the script.

Below is the HTML-based recorded request, You can see that there are four data items of grid results,

“Name=SearchResultsGrid_ctl03_ViewPackageDialogResult”, “Value={c_PackageID}”, ENDITEM,
“Name=SearchResultsGrid_ctl04_ViewPackageDialogResult”, “Value=291570”, ENDITEM,
“Name=SearchResultsGrid_ctl08_ViewPackageDialogResult”, “Value=291566”, ENDITEM,
“Name=SearchResultsGrid_ctl11_ViewPackageDialogResult”, “Value=291563”, ENDITEM,
“Name=SearchResultsGrid_ctl12_ViewPackageDialogResult”, “Value=291562”, ENDITEM,

Below is the custom request which is URL-based,

“URL=http:// {p_Url}/site/secure/reportcenter/managepackages.aspx”,
“Referer= http://{p_Url}/site/secure/reportcenter/managepackages.aspx”,
/*//below string is going to vary every time so we are going to manipulate it every time using string manipulation functions//


In custom request you can manipulate final string every time using string manipulation functions available in VuGen.

final_string= &SearchResultsGrid_ctl04_ViewPackageDialogResult=291570




P.S. : Thanks to Kranti.

Scripting for Microsoft ASP.NET VIEWSTATE in VuGen LoadRunner

ASP.NET web applications maintain state of data by passing hidden _VIEWSTATE field encoded using base64 algorithm. The state of the page is restored based on the VIEWSTATE. If on the client side, the value of textbox has been changed, VIEWSTATE will now have the new value. (Obviously, this stage does not happen when the page is requested for the first time).

Let’s see how Web Applications developer store objects in VIEWSTATE,

// Storing a Customer object in view state.
Customer cust = new Customer (“Dilip”, “Kalyankar”);
ViewState[“CurrentCustomer”] = cust;

// Retrieve a student from view state.
Customer cust = (Customer) ViewState[“CurrentCustomer”];

Now we will see how to capture and replace VIEWSTATE in a recorded script,

1. First set the html parameter length to maximum so that it can store VIEWSTATE, You can adjust this number after examining the captured value.


2. Capture the VIEWSTATE value when it is returned from the server using web_reg_save_param() function

web_reg_save_param(“MyViewState”,”LB=\”__VIEWSTATE\” value=\””,”RB=\””,”ORD=ALL”,LAST);

3. Substitute the captured value with the parameter name in which you captured the VIEWSTATE:

“Name=__VIEWSTATE”, “value={MyViewState}”, ENDITEM,

4. Run the script (with enabled advanced log) in VuGen and verify that the correlation function is capturing the right value.

Base 64 encoding in loadRunner

There are some secure applications which provide certain functionality to protect important data. Those applications use algorithms to encode secured data before sending from the client and decoding algorithms to decode data at server side.
There are many algorithms which do encoding and decoding for you. Let us consider one,
Base-64 algorithm encodes the plain text into 64-bit encoded format.
[cce lang=”c”]

/*Plain Text: */
/*Encoded Text:*/
Secured applications use this type of encoder to encode data at client side, so that no one can read the important data. Applications use JavaScript to get this done at client side.
When you record the script for this type of applications you will find some random characters in script. If application is sending these random characters in the request body then you should know what these characters stand for. Without decoding that encoded string you cannot correlate them. To correlate them follow the below steps,
• From the generation log find out which encoding algorithm application is using.
• There are many websites available on the internet, which provide online tool for encoding and decoding. E.g.
• Decode the encoded string and do correlation for those values.
• Prepare the exact string using string tokenizer
• Encode the final string and put it in the request.
[cce lang=”c”]
“URL= saveParameters.jsp”,
“, LAST);
Decode the above encoded string and capture the dynamic values accordingly. Create a string with dynamic values and pass it as parameter to the base-64 encoding algorithm function.
Put the below given functions in globals.h
[cce lang=”c”]
#ifndef _GLOBALS_H
#define _GLOBALS_H
/* Include Files*/
#include “lrun.h”
#include “web_api.h”
#include “lrw_custom_body.h”
/* Global Variables*/
#endif // _GLOBALS_H
/*Converting into Base-64 encoding*/
char *convert( char *src)
int dest_size;
char *deststr;
/* Allocate dest buffer*/
dest_size = 1 + ((strlen(src)+2)/3*4);
deststr = (char *)malloc(dest_size);
base64encode(src, deststr, dest_size);
return deststr;
void base64encode(char *src, char *dest, int len)
/* Encodes a buffer to base64*/
char base64encode_lut[] = {
int i=0, slen=strlen(src);
*dest=’\0′; /* Append terminator*/

Preparing the query string & passing to base-64 encoding
[cce lang=”c”]
char *getParam(char *str, char *param1, char *param2,char *param3)
char *temp;
char *src, *target;
char param[200];
strcat(param, “txnPayPayRefNumber=”);
strcat(param, “txnBatchRefNumber=”);
src=(char *) param;
return target;

Call the above functions as below in the script, capture the return value into a parameter & substitute it.
[cce lang=”c”]
lr_save_string( getParam(“action=INIT&state=ViewTransfer_”,
“param” );
Final string:

LoadRunner Flex / amf Protocol


Flex software development kit provides user interface components like button, data grids, layouts. Flex work as a presentation layer for n-tier web applications.

It maintains a state, where it can send, receive data from server side without reloading the page. Flex works just like AJAX.

Working on Flex Protocol

1. Choose multi protocol recording and select Web, Flex or Web, AMF protocol depending on the requirement.

2. Set the Flex code generation options and don’t forget to provide path of the flex jar files. To Get valid xml we require jar files, which were used by developers like,

  • flex-messaging-core.jar
  • flex-messaging-common.jar
  • flex-messaging-opt.jar
  • flex-messaging-proxy.jar
  • flex-messaging-remoting.jar

3. Start recording the business flow. After completion of recording, in the script you can see the there are flex_amf_call with BEGIN_ARGUMENTS, then XML formatted values and END_ARGUMENTS.

4. To correlate the values in amf request, go to tree view .

5. Find the dynamic value in xml grid of the response and right click and create a parameter.

6. Provide file name and parameter name where you want to capture the dynamic value.

7. Then replace all the instances of that value in the script with the created parameter.

P.S. : Thanks to Rahul Awasthi.

LoadRunner Naming Standards

S.No Area Description
1 Script Name ApplicationName_Goal_NumberIndex_BusinessTransactionName_Version
2 Script Description Verify whether the Script included with below fields with description in Vuser_init block
Script Objective
Script Description
Revision History (Version and Comments)
3 Script Enhancement Verify each business transaction corresponds to a unique action
Verify any spaces exist while defining Action names
Verify Action names are defined with first letter in Capitals
Verify While naming Action names, underscore is used as separator
Verify whether all other actions are referring to the Main Action
Verify whether all functions referred within Main Action are spelt correctly
4 Error Handling Verify whether Conditional Pass/Failure is handled with LR_PASS and LR_FAIL.LR_AUTO should not be used
Verfiy whether  rules are created to enable global error handling mechanism
5 Parameterization Verify whether ” p_ ” is used prior to the parameter name to differentiate parameter from a variable
Verify whether all dynamic values generated from or passed to the server are correlated using web_reg_save_param
Verify whether all domain URL’s, UserID/Passwored and controlled variables are parameterized using lr_save_string or as a parameter list file
6 Correlation Verify whethere While Correlating dynamic values is Correlation rule file is used?
7 Variable Declaration Verify whether all Global Variables are placed outside of Functions/Actions?
Verify whether  Vuser_init action contains all of the variable declarations for file manipulation
Verify whether all variable declarations follow below naming convention:
iName = integer
sName = Char or Char *
8 Comments Verify whether  “//” are used instead of /* */ while commenting.
Verify whether every function/action is included with descriptive comments
9 Run Time Settings Verify whether in Miscellaneous settings if the below options are checked
Run Vuser as a thread
Define each action as a transaction
Verify whether in Preferences settings, check whether below options are selected
Hits per second and HTTP Codes
Pages per second(HTML mode only)
Response byte per second
Non Critical resource errors as warning
Verify whether  text check, image and content check are used with discretion
10 Load Test Name Verify naming convention for Load Test Name is followed in the below format:
11 Load Test Description Verify Load test description format as below:
Ex: Measure the system performance of application release 1.0 using 10 Virtual users of the following business transactions

How to capture and save file on local machine in VuGen LoadRunner

As we know LoadRunner does not recognize the Client side activities, so the activity of saving file on local machine will not be recorded by LoadRunner. Below is the one way to resolve this.

Just before the URL which opens the PDF, capture the whole page into a string through correlation and write the captured string into a PDF file using File handling.

Sample Code:

Code Captures the PDF value in variable – c_PDF_Data

[cc lang=”c”]

char * filename = “c:\\PerfTuit.pdf”;
long File_Size;
long Download_time;
long HttpRetCode;
long file;
int flag;

/*Set the parameter size large enough to save the data.*/


/*Mention left and right boundary as blank of web_reg_save_param function to capture the pdf returned by the server.*/

web_reg_save_param(“c_PDF_Data “,”LB=”,”RB=”,”Search=Body”,LAST);

/*get the loading of PDF status in flag */


“Action=http://{p_SampleURL}/subDomain/area/ PerfTuit.aspx”,








lr_error_message(“status fail”);



/* we have captured the pdf file into string, Now we will write the captured string into the PDF file.*/

/*First we will save the size of downloaded file into variable named sizePDF*/

File_Size= web_get_int_property(HTTP_INFO_DOWNLOAD_SIZE);

/* other details*/

Download_time = web_get_int_property( HTTP_INFO_DOWNLOAD_TIME );

HttpRetCode = web_get_int_property( HTTP_INFO_RETURN_CODE );

lr_output_message(“File size is %d “,  File_Size);

lr_output_message(“Download Time is %d “,  Download_time);

lr_output_message(“HTTP Return Code is %d “,  HttpRetCode);

/*Write the string captured into file.*/
if ((file = fopen(filename, “w+”)) == NULL) {

lr_output_message (“Unable to create %s”, filename);

return -1;

fwrite(lr_eval_string(“{c_PDF_Data}”), File_Size, 1, file);




To make to test run as realistic as possible we need to make scripts dynamic. We can do that using parameterization and correlation.

How to find dynamic values:

We only correlate values which are dynamic. To find dynamic values replay the recorded script, if script fails then double click on the error in replay log it will highlight the request in script where it got fail. In that request see if there are values like session-id, view state. These are the values we should correlate. Another way is to record two scripts of same application flow but with different user-ids and compare them with the wdiff utility available in LoadRunner. Note the values which are different in two scripts and see if we are passing them in Vuser script request. These are the values we should correlate.

There are two ways of doing correlation,

Automatic Correlation: HP LoadRunner provides facility of Automatic Correlation. Replay the script once and then press Ctrl+F8, tool will automatically find values which are dynamic according to LoadRunner dynamic values rule. If you are recording banking and finance web application, most of the time Automatic Correlation doesn’t work. By doesn’t work I mean it say there are no values to correlate, but when we replay the script it gets failed, so in that case we have to do manual correlations.

Manual Correlation: In manual correlation we have to find the values which are dynamic like session-id, view-state and write web_reg_save_param() function to capture those dynamic values into a parameter and replace the occurrence of that value in sub-sequent requests with it.

There are three ways of doing Manual Correlation:

1. Using Generation Log:

First search the dynamic value in Generation Log. When you find it make sure that value is in response not in request. Copy the left and right boundary of that value.

Note: left boundary should be accurate, because if you misspelled the left boundary web_reg_save_param() function will get fail to find that value.

To find the request in whose response that dynamic value is coming. Press Ctrl+f, find keyword add event and note the below request URL or name because we have to put our web_reg_save_param() function right above that request.

When we put our web_reg_save_param() in the script it register the parameter to find the value with mentioned left and right boundary in the below request and save it in the parameter.

2. Using Tree View:

We can do the correlation using Tree view. Click on the Tree View button located on the top panel. It will show you the Page view, Request and response. Find the dynamic value in the response tab, then right click and create parameter.

It will automatically create web_reg_save_param() function. You can check it in the script view.

3.Using Replay Log:

if you are not able to do correlation Using Generation Log and Using Tree View, the last option is to use Replay Log. To do correlation using replay log go to log settings,

Enable all options present in extended log and run the script it will print everything from parameter substitution to the data returned by server in replay log. Then find the dynamic value in replay log, note that left and right boundary and double click on that value it will highlight the request in script. Put your web_reg_save_param() function above that request.

Replacing the original value with captured value:

The web_reg_save_param() function stores the captured value in the parameter we mentioned at the time of declaration. We have to replace all the original value with the captured value so that every time it will put the current value of session-id or view states not the value at the time of recording. To do this press Ctrl+H to find and replace, replace all the original values with name of parameter and flower braces.



When we want to test the performance of the web application, we want to check the capability of the system. To do that, we need set of virtual users with test data to apply load on application. So to maintain that test data parameterization comes in picture.

Parameter is nothing but a variable like,
int thinkTime=5;

In LoadRunner we specify:

Parameter Name

Parameter Type

Parameter Value

<< Playing Back Your Script                                Correlations >>

Playing Back Your Script

By recording a set of typical user actions such as booking flight, you created real user emulation. You replay your recorded script to verify that it runs properly before you incorporate it into a load testing scenario. During replay, you can view the actions in a browser and see if everything is as you expect it be. If the script doesn’t replay properly, you may need to add correlations.

Before replaying the script, you can configure run-time settings, which help you set the behaviour of the Vuser.

  • How do I set the run-time behaviour?
  • How do I watch my script running in real time?
  • Where can I view information about the replay?
  • How do I know if my test passed?
  • How do I search in or filter the results?

How do I set the run-time behaviour?

LoadRunner Run-Time settings let you emulate different kinds of real user activity and behaviour. For example, you could emulate a user who responds immediately to output from the server, or a user who stops and thinks before each response. You can also configure run-time settings to specify how many times the Vuser should repeat a set of actions and how often.

There are general run-time settings, and settings that are specific to certain Vuser types. For example, for Web emulation, you could instruct your Vusers to replay your script in Netscape instead of Internet Explorer

  • Run Logic: the number of repetitions
  • Pacing: the time to wait between repetitions
  • Think Time: the time the user stops to think between steps
  • Log: the level of information that you want to gather during playback

Note that you can also modify the run-time settings from the LoadRunner Controller or in Performance Center.

1 Open the run-time settings.

You can press F4 or click the Run-Time Settings button in the toolbar. The Run-Time settings dialog box opens.

2 Open the Run Logic settings.

Select the Run Logic node.

In this node you set the number of iterations, or the number of times to repeat the activity in succession. Set the number of iterations to 2.

3 Set the Pacing settings.

Select the Pacing node.

This node lets you control the time between iterations. You will specify a random time. This accurately emulates a real-life setting where the user waits between actions, but at random intervals—you don’t see real users waiting exactly 60 seconds between repetitions.

Choose the third option and select the following:

At random intervals every 60.00 to 90.00 seconds.

4 Set the Log settings.

Select the Log node.

The Log settings indicate how much information to log while running the test. During development, you may choose to enable some logging for debugging purposes, but once you verify that your script is functional, you can enable logging for errors only or disable it.

Select Extended log and enable Parameter substitution.

5 View the Think Time settings.

Select the Think Time node.

Do not make any changes. You will set the think-time from the Controller. Keep in mind that when you run the script in VuGen, it will run quickly since it will not include think-time.

6 Click OK to close the Run-Time Settings dialog box.

How do I watch my script running in real time?

VuGen’s run-time viewer feature displays the Vuser activities in real time as you playback the recorded script.

By default, VuGen runs your test in the background, without displaying an animation of the actions in your script. For this tutorial, however, you will instruct VuGen to display the actions in a viewer that lets you see how VuGen executes each step. The viewer is not an actual browser—it only displays snapshots of the pages that are returned to the Vuser.

1 Choose Tools > General Options and select the Display tab.

2 Select the Show browser during replay and Auto arrange window options.

3 Click OK to close the General Options.

4 Press F5 or click the Run button in the tool bar.

5 After a few moments, VuGen opens a run-time viewer and begins running the script in either script view or tree view, depending on what you last had open. In the run-time viewer, you visually observe the Vuser’s actions. Note how the replay is an exact playback of the steps you performed during recording.

Where can I view information about the replay?

When the script stops running, you can view a summary of the replay in the wizard. Click Verify Replay in the Task Pane to view the Last Replay Summary.

The Last Replay Summary lists any errors that may have been detected and displays thumbnails of the Recording and Replay snapshots. You can compare snapshots and look for discrepancies between your recording and the replay.

You can also look at the Vuser’s activity by reviewing a textual summary of the events. VuGen’s Replay Log tab in the Output window shows this colour coded information.

To view the replay log:

1 Click the replay log hyperlink in the instruction pane. Alternatively click the Show/Hide output button in the toolbar or choose View > Output Window from the menu. Then click the Replay Log tab.

2 Press Ctrl+F in the replay log to open the Find dialog box. Locate the following items:

  • Started, Terminated: the beginning and end of the script run—Virtual User Script Started, Vuser Terminated.
  • Iteration: the beginning and end of the iteration and the iteration number (orange lettering).

VuGen displays successful steps in green and errors in red. For example, if your connection broke in the middle of the test, VuGen indicates the line number of the error and displays the whole line in red text.

3 Double-click on a line in the replay log. VuGen takes you to the corresponding step in the script. A vertical black line on the left side of the script view indicates this step.

How do I know if my test passed?

After you playback the events that you recorded, you need to look at the results and see if everything succeeded. If something failed, you want to know why and when it failed.

In this section you will view and analyze the results of your script run. VuGen summarizes the results of the replay in the Test Results window.

To view test results:

1 Choose View > Test Results. A new results window opens.

When the Test Results window first opens, it contains two panes: Tree pane (on the left) and Summary pane (on the right).

The Tree pane contains the results tree. Each iteration is numbered. The Summary pane contains the details of the test.

<< Create New Script                                Parameterization >>

Interview Questions

  1. What is load testing? – Load testing is to test that if the application works fine with the loads that result from large number of simultaneous users, transactions and to determine whether it can handle peak usage periods.
  2. What is Performance testing? – Timing for both read and update transactions should be gathered to determine whether system functions are being performed in an acceptable timeframe. This should be done standalone and then in a multi user environment to determine the effect of multiple transactions on the timing of a single transaction.
  3. Did u use LoadRunner? What version? – Yes. Version 9.5.
  4. Explain the Load testing process?
    Step 1: Planning the test. Here, we develop a clearly defined test plan to ensure the test scenarios we develop will accomplish load-testing objectives. Step 2: Creating Vusers. Here, we create Vuser scripts that contain tasks performed by each Vuser, tasks performed by Vusers as a whole, and tasks measured as transactions. Step 3: Creating the scenario. A scenario describes the events that occur during a testing session. It includes a list of machines, scripts, and Vusers that run during the scenario. We create scenarios using LoadRunner Controller. We can create manual scenarios as well as goal-oriented scenarios. In manual scenarios, we define the number of Vusers, the load generator machines, and percentage of Vusers to be assigned to each script. For web tests, we may create a goal-oriented scenario where we define the goal that our test has to achieve. LoadRunner automatically builds a scenario for us. Step 4: Running the scenario.
    We emulate load on the server by instructing multiple Vusers to perform tasks simultaneously. Before the testing, we set the scenario configuration and scheduling. We can run the entire scenario, Vuser groups, or individual Vusers. Step 5: Monitoring the scenario. We monitor scenario execution using the LoadRunner online runtime, transaction, system resource, Web resource, Web server resource, Web application server resource, database server resource, network delay, streaming media resource, firewall server resource, ERP server resource, and Java performance monitors. Step 6: Analyzing test results. During scenario execution, LoadRunner records the performance of the application under different loads. We use Loadrunner’s graphs and reports to analyze the application’s performance.
  5. When do you do load and performance Testing? – We perform load testing once we are done with interface (GUI) testing. Modern system architectures are large and complex. Whereas single user testing primarily on functionality and user interface of a system component, application testing focuses on performance and reliability of an entire system. For example, a typical application-testing scenario might depict 1000 users logging in simultaneously to a system. This gives rise to issues such as what is the response time of the system, does it crash, will it go with different software applications and platforms, can it hold so many hundreds and thousands of users, etc. This is when we set do load and performance testing.
  6. What are the components of LoadRunner? – The components of LoadRunner are The Virtual User Generator, Controller, and the Agent process, LoadRunner Analysis and Monitoring, LoadRunner Books Online.
  7. What Component of LoadRunner would you use to record a Script? – The Virtual User Generator (VuGen) component is used to record a script. It enables you to develop Vuser scripts for a variety of application types and communication protocols.
  8. What Component of LoadRunner would you use to play back the script in multi user mode? – The Controller component is used to playback the script in multi-user mode. This is done during a scenario run where a Vuser script is executed by a number of Vusers in a group.
  9. What is a rendezvous point? – You insert rendezvous points into Vuser scripts to emulate heavy user load on the server. Rendezvous points instruct Vusers to wait during test execution for multiple Vusers to arrive at a certain point, in order that they may simultaneously perform a task. For example, to emulate peak load on the bank server, you can insert a rendezvous point instructing 100 Vusers to deposit cash into their accounts at the same time.
  10. What is a scenario? – A scenario defines the events that occur during each testing session. For example, a scenario defines and controls the number of users to emulate, the actions to be performed, and the machines on which the virtual users run their emulations.
  11. Explain the recording mode for web Vuser script? – We 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. For example, in web based applications, VuGen monitors the client end of the database and traces all the requests sent to, and received from, the database server. We use VuGen to: Monitor the communication between the application and the server; Generate the required function calls; and Insert the generated function calls into a Vuser script.
  12. Why do you create parameters? – Parameters are like script variables. They are used to vary input to the server and to emulate real users. Different sets of data are sent to the server each time the script is run. Better simulate the usage model for more accurate testing from the Controller; one script can emulate many different users on the system.
  13. What is correlation? Explain the difference between automatic correlation and manual correlation? – Correlation is used to obtain data which are unique for each run of the script and which are generated by nested queries. Correlation provides the value to avoid errors arising out of duplicate values and also optimizing the code (to avoid nested queries). Automatic correlation is where we set some rules for correlation. It can be application server specific. Here values are replaced by data which are created by these rules. In manual correlation, the value we want to correlate is scanned and create correlation is used to correlate.
  14. How do you find out where correlation is required? Give few examples from your projects? – Two ways: First we can scan for correlations, and see the list of values which can be correlated. From this we can pick a value to be correlated. Secondly, we can record two scripts and compare them. We can look up the difference file to see for the values which needed to be correlated.  In my project, there was a unique id developed for each customer, it was nothing but Insurance Number, it was generated automatically and it was sequential and this value was unique. I had to correlate this value, in order to avoid errors while running my script. I did using scan for correlation.
  15. Where do you set automatic correlation options? – Automatic correlation from web point of view can be set in recording options and correlation tab. Here we can enable correlation for the entire script and choose either issue online messages or offline actions, where we can define rules for that correlation. Automatic correlation for database can be done using show output window and scan for correlation and picking the correlate query tab and choose which query value we want to correlate. If we know the specific value to be correlated, we just do create correlation for the value and specify how the value to be created.
  16. What is a function to capture dynamic values in the web Vuser script? – Web_reg_save_param function saves dynamic data information to a parameter.
  17. When do you disable log in Virtual User Generator, When do you choose standard and extended logs? – Once we debug our script and verify that it is functional, we can enable logging for errors only. When we add a script to a scenario, logging is automatically disabled. Standard Log Option: When you select
    Standard log, it creates a standard log of functions and messages sent during script execution to use for debugging. Disable this option for large load testing scenarios. When you copy a script to a scenario, logging is automatically disabled Extended Log Option: Select
    extended log to create an extended log, including warnings and other messages. Disable this option for large load testing scenarios. When you copy a script to a scenario, logging is automatically disabled. We can specify which additional information should be added to the extended log using the extended log options.
  18. How do you debug a LoadRunner script? – VuGen contains two options to help debug Vuser scripts-the Run Step by Step command and breakpoints. The Debug settings in the Options dialog box allow us to determine the extent of the trace to be performed during scenario execution. The debug information is written to the Output window. We can manually set the message class within your script using the lr_set_debug_message function. This is useful if we want to receive debug information about a small section of the script only.
  19. How do you write user defined functions in LR? Give me few functions you wrote in your previous project? – Before we create the User Defined functions we need to create the external library (DLL) with the function. We add this library to VuGen bin directory. Once the library is added then we assign user defined function as a parameter. The function should have the following format: __declspec (dllexport) char* <function name>(char*, char*)Examples of user defined functions are as follows:GetVersion, GetCurrentTime, GetPltform are some of the user defined functions used in my earlier project.
  20. What are the changes you can make in run-time settings? – The Run Time Settings that we make are: a) Pacing – It has iteration count. b) Log – Under this we have Disable Logging Standard Log and c) Extended Think Time – In think time we have two options like Ignore think time and Replay think time. d) General – Under general tab we can set the Vusers as process or as multithreading and whether each step as a transaction.
  21. Where do you set Iteration for Vuser testing? – We set Iterations in the Run Time Settings of the VuGen. The navigation for this is Run time settings, Pacing tab, set number of iterations.
  22. How do you perform functional testing under load? – Functionality under load can be tested by running several Vusers concurrently. By increasing the amount of Vusers, we can determine how much load the server can sustain.
  23. What is Ramp up? How do you set this? – This option is used to gradually increase the amount of Vusers/load on the server. An initial value is set and a value to wait between intervals can be specified. To set Ramp Up, go to ‘Scenario Scheduling Options’
  24. What is the advantage of running the Vuser as thread? – VuGen provides the facility to use multithreading. This enables more Vusers to be run per generator. If the Vuser is run as a process, the same driver program is loaded into memory for each Vuser, thus taking up a large amount of memory. This limits the number of Vusers that can be run on a single
    generator. If the Vuser is run as a thread, only one instance of the driver program is loaded into memory for the given number of Vusers (say 100). Each thread shares the memory of the parent driver program, thus enabling more Vusers to be run per generator.
  25. If you want to stop the execution of your script on error, how do you do that? – The lr_abort function aborts the execution of a Vuser script. It instructs the Vuser to stop executing the Actions section, execute the vuser_end section and end the execution. This function is useful when you need to manually abort a script execution as a result of a specific error condition. When you end a script using this function, the Vuser is assigned the status “Stopped”. For this to take effect, we have to first uncheck the .Continue on error. Option in Run-Time Settings.
  26. What is the relation between Response Time and Throughput? – The Throughput graph shows the amount of data in bytes that the Vusers received from the server in a second. When we compare this with the transaction response time, we will notice that as throughput decreased, the response time also decreased. Similarly, the peak throughput and highest response time would occur approximately at the same time.
  27. Explain the Configuration of your systems? – The configuration of our systems refers to that of the client machines on which we run the Vusers. The configuration of any client machine includes its hardware settings, memory, operating system, software applications, development tools, etc. This system component configuration should match with the overall system configuration that would include the network infrastructure, the web server, the database server, and any other components that go with this larger system so as to achieve the load testing objectives.
  28. How do you identify the performance bottlenecks? – Performance Bottlenecks can be detected by using monitors. These monitors might be application server monitors, web server monitors, database server monitors and network monitors. They help in finding out the troubled area in our scenario which causes increased response time. The measurements made are usually performance response time, throughput, hits/sec, network delay graphs, etc.
  29. If web server, database and Network are all fine where could be the problem? – The problem could be in the system itself or in the application server or in the code written for the application.
  30. How did you find web server related issues? – Using Web resource monitors we can find the performance of web servers. Using these monitors we can analyze throughput on the web server, number of hits per second that
    occurred during scenario, the number of http responses per second, the number of downloaded pages per second.
  31. How did you find database related issues? – By running Database monitor and help of Data Resource Graph. We can find database related issues. E.g. you can specify the resource you want to measure on before running the controller and then you can see database related issues.
  32. Explain all the web recording options?Here you specify HTML or URL base recording.
  33. What is the difference between Overlay graph and Correlate graph?Overlay Graph: It overlay the content of two graphs that shares a common x-axis. Left Y-axis on the merged graph shows the current graph’s value & Right Y-axis show the value of Y-axis of the graph that was merged. Correlate Graph: Plot the Y-axis of two graphs against each other. The active graph’s Y-axis becomes X-axis of merged graph. Y-axis of the graph that was merged becomes merged graph’s Y-axis.
  34. How did you plan the Load? What are the Criteria? – Load test is planned to decide the number of users, what kind of machines we are going to use and from where they are run. It is based on 2 important documents, Task Distribution Diagram and Transaction profile. Task Distribution Diagram gives us the information on number of users for a particular transaction and the time of the load. The peak usage and off-usage are decided from this Diagram. Transaction profile gives us the information about the transactions name and their priority levels with regard to the scenario we are deciding.
  35. What does vuser_init action contain? – Vuser_init action contains procedures to login to a server.
  36. What does vuser_end action contain? – Vuser_end section contains log off procedures.
  37. What is think time? How do you change the threshold? –   Think time is the time that a real user waits between actions. Example: When a user receives data from a server, the user may wait several seconds to review the data before responding. This delay is known as the think time. Changing the Threshold: Threshold level is the level below which the recorded think time will be ignored. The default value is five (5) seconds. We can change the think time threshold in the Recording options of the VuGen.
  38. What is the difference between standard log and extended log? – The standard log sends a subset of functions and messages sent during script execution to a log. The subset depends on the Vuser type Extended log sends a detailed script execution messages to the output log. This is mainly used during debugging when we want information about: Parameter substitution, Data returned by the server, advanced trace.
  39. Explain the following functions:lr_debug_message – The lr_debug_message function sends a debug message to the output log when the specified message class is set. lr_output_message – The lr_output_message function sends notifications to the Controller Output window and the Vuser log file. lr_error_message – The lr_error_message function sends an error message to the LoadRunner Output window. lrd_stmt – The lrd_stmt function associates a character string (usually a SQL statement) with a cursor. This function sets a SQL statement to be processed. lrd_fetch – The lrd_fetch function fetches the next row from the result set.
  40. ThroughputIf the throughput scales upward as time progresses and the number of Vusers increase, this indicates that the bandwidth is sufficient. If the graph were to remain relatively flat as the number of Vusers increased, it would
    be reasonable to conclude that the bandwidth is constraining the volume of
    data delivered.
  41. Types of Goals in Goal-Oriented Scenario – Load Runner provides you with five different types of goals in a goal oriented scenario: 1)The number of concurrent Vusers, 2)The number of hits per second, 3)The number of transactions per second, 4)The number of pages per minute, 5)The transaction response time that you want your scenario
  42. Analysis Scenario (Bottlenecks): In Running Vuser graph correlated with the response time graph you can see that as the number of Vusers increases, the average response time of the check itinerary transaction very gradually increases. In other words, the average response time steadily increases as the load
    increases. At 56 Vusers, there is a sudden, sharp increase in the average response
    time. We say that the test broke the server. That is the mean time before failure (MTBF). The response time clearly began to degrade when there were more than 56 Vusers running simultaneously.
  43. What is correlation? Explain the difference between automatic correlation and manual correlation? – Correlation is used to obtain data which are unique for each run of the script and which are generated by nested queries. Correlation provides the value to avoid errors arising out of duplicate values and also optimizing the code (to avoid nested queries). Automatic correlation is where we set some rules for correlation. It can be application server specific. Here values are replaced by data which are created by these rules. In manual correlation, the value we want to correlate is scanned and create correlation is used to correlate.
  44. Where do you set automatic correlation options? – Automatic correlation from web point of view can be set in recording options and correlation tab. Here we can enable correlation for the entire script and choose either issue online messages or offline actions, where we can define rules for that correlation.  Automatic correlation for database can be done using show output window and scan for correlation and picking the correlate query tab and choose which query value we want to correlate. If we know the specific value to be correlated, we just do create correlation for the value and specify how the value to be created.
  45. What is a function to capture dynamic values in the web Vuser script? – Web_reg_save_param function saves dynamic data information to a parameter.

Create New Script

In the workload modelling you decide the flows in application to record. So before you start recording the script, you should have the following details of the application,


For example:




Application flow to record:

Once you have above details you can start recording the script using VuGen -> New Script

1. Click New Vuser Script in the Scripts tab in the VuGen Start Page.

The New Virtual User dialog box opens, displaying the options for a new single protocol script.

It shows the list of all protocols supported by VuGen. Make sure the Category type is All Protocols. VuGen displays a list of all of the available protocols for a single protocol script. Scroll down the list, select Web (HTTP/HTML), and click OK to create an empty Web script.

Choose Vuser > Start Record or click the Start Record button in the Toolbar at the top of the page.

Enter the URL of the application and in the Record into Action choose Action.

Note: After recording you can modify the action name and the codes in it

Click on Options button, It will take you to Recording Options window.

In the General tree select Script, here you can choose the language in which you want VuGen to record the script. Languages like C, Java. Depending on the license constraint you can choose the language.

In the General tree select Protocols, it will show the selected protocol.

Select Recording it will show two options HTML-based scripts, URL-based scripts. Choose former it is easy to work with. But depending on the requirement you can choose URL-based script, conditions like catching correlations.

Click Ok and start recording.

Your application will be opened in Internet explorer and the floating Recording toolbar opens.

2. Log on to the web application.

Enter the User and Password. Click Login

3. Record the application flow mentioned in the requirement. Follow the below given nomenclature while giving the Action and transaction names:



4. Insert Comments for better understanding

5. Insert content check by selecting the text on the page. We can use this to check if the page is loading properly or not.

6. Log off if it is mentioned in the application flow.

7. Click Stop on the floating toolbar to stop the recording process.

8. The Code Generation pop up window opens while the Vuser script is being generated.

9. Choose File > Save. VuGen saves the file in the LoadRunner script folder and displays the test name in the title bar.

You have now recorded a web application flow logging in, booking flight and logging off. VuGen recorded your steps from the moment you clicked the Start Record button to the moment you clicked the Stop button.

You can now view the script inside VuGen. You can view the script in Tree view or Script view.

Script view is a text-based view that lists the actions of the Vuser as API functions. To view the script in Script view choose View > Script View or click the Script View button.

In Script view, VuGen shows the script in an editor with colour coded functions and their argument values. You can type C or LoadRunner API functions, as well as control flow statements, directly into this window.

Note: LoadRunner uses ANSI C. As your scripts become more advanced, you can leverage C to extend LoadRunner beyond record and playback.

Playing Back Your Script >>


A script is a programming code written in languages like C, Java to emulate the steps of real human users. Scripting can be done manually by user or one can generate automatically with help of tools like Virtual User Generator (VuGen).

Working on Scripts:

If you know the answers of below questions then you are done with basics of scripting.

  • What are the prerequisite before you start scripting?
  • What are the recording options settings?
  • How to record script?
  • What are the Changes to make before playback?
  • How to do Parameterizations?
  • How to do Correlations?


HP LoadRunner supports more than 51 protocols including Web HTTP/HTTPS, Remote Terminal Emulator, Oracle and Web Services. A protocol acts as a communication medium between a client and a server. For example an on-line banking application can use HTTP/HTTPS with some Java and Web services. LoadRunner can record scripts in both single and multi-protocol modes.

During recording, VuGen records a tester’s actions by routing data through a proxy. The type of proxy depends upon the protocol being used and affects the resulting script.

Create New Script >>