Friday 13 December 2013

Why do we need Correlation Studio?When we use Correlation studio in vugen Load runner

Creating of correlation studio will be useful when there are multiple scripts to be recorded (more than 2/3) on same or similar application. Bulding correlation studio just for script is a waste of time.
Process to Create .cor file:

Record first script normally without any correlation and do all correlations maually and import that vugen before recording the remaining scripts. So that the remaining all scripts will be auto correlated when they are recorded.
Detailed step by step decription

Step 1: Record first script and identify all the required correlation patterns like variable, its left boundary abd right boundary.

Step 2: Go to Recording Options in vugen, HTTP Properties> Correlation and uncheck all the exsisting patterns.



Step 3: Click on New Application button



Step 4: Click on New Rule and enter Variable name, Lift boundary, Right boundary and Where to search that pattern in the response.



  • Action->Where to search for the pattern
  • Left boundary-> Left boundary of the variable that you want to correlate
  • Right boundary-> Right boundary of the variable that you want to correlate
  • Parameter Prefix-> Variable name(not mandatory)

Step 5
: In the Same way you can add multiple rules as required.




Note:we should enable the check box "Enable correlation during recording" .its mandatory

Step 6:
After completion of adding all the rules Click on Export button


Check the required Applications and again Click on Export.

You can give the name as you like and save it. File will be of extention *.cor

Now the file is created you can use for further correlation values as same 


Date and Time parameters in vugen scripting Loadrunner

Some applications need you to provide date and time in the requests. 
After scripting completed,If you would like to get access to the current date, the easiest way is to create a new parameter with Date/Time type. for that select the date in script and right click on it "Replace with a parameter"  give a name to your new parameter set the parameter type to “Date/Time”. then Open the Parameter List dialog by pressing
Ctrl+L
In the Date/Time format list you can choose your desired date format, or create a custom one.

Pay attention to the “Update value on” drop-down box,as shown in the below screen here you can select when the value of the date/time parameter is to update like
  •  each occurrence
  • each iteration
  • only once




Note:Use this with care because you have access not only to the current date or time, but you can also offset it with a defined date or time. This can also factor in working days.

If the Application Under Test uses different date or time formats then you will probably need a different approach.

example: A multinational site, serving UK and US where the date formats are different

Condition: It is possible to define multiple variants of the parameter (e.g. one to match US date format and one other to match UK), or this can be done programmatically.

Here is an example of the Load runner code to deal with this type of problem:

void saveFutureDate(int daysInFuture, char *paramName) {
char *dateFormat;
char *locale = lr_eval_string("{p_locale}");
if (strcmp(locale, "UK")==0) {
dateFormat = "%d-%m-%Y";
} else if (strcmp(pos, "US")==0) {
dateFormat = "%m-%d-%y";
} else {
dateFormat = "%Y-%m-%d"; // a default date format...
}
lr_save_datetime(dateFormat, DATE_NOW + ONE_DAY * daysInFuture, paramName);
web_convert_param(paramName, "SourceEncoding=PLAIN", "TargetEncoding=URL", LAST);
}


This functions sets the desired Loadrunner parameter with a date in a specified day offset in the future.

The function considers two date format, a UK and a US specific one. The right format is decided according to the “p_locale” parameter. Specify this it in a Parameter list with an appropriate selection strategy – random or sequential, or simply set it programatically with lr_save_string() before invoking this function.

As a bonus, the function also converts the parameter to URL-encoded, so you can simply apply it later in a web request.

Here is a code snippet how to use it:

lr_save_string("US", "p_locale");
saveFutureDate( 10, "p_arrivalDate"); // arrival Date will be 10 days ahead from now

web_url("List Intineraries",
"URL=http://www.yourapplication.com/usa/listBookings.html?arrivalDate={p_arrivalDate}",
"Resource=0",
"RecContentType=text/html",
"Referer=http://www.yourapplication.com/usa/",
"Snapshot=t33.inf",
"Mode=HTML",
LAST);