Wednesday, December 11, 2013

How to handle java script generated Session ID in Vugen using Load runner

A session id (GUID) is generated on client side via a javascript and sent to the server. This cannot be correlated because it doesn’t come from the server.

You will need to figure this out from the page source. In my case, the sessionID is assigned a value of window.SessionId where window.SessionID = NewGuid()

The body of NewGuid() is -

function NewGuid() {
-------
-Creates a new pseudo GUID.
------

var guid = ‘xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx’.replace(/[xy]/g, function (c) {
var r = Math.random() * 16 | 0, v = c == ‘x’ ? r : (r & 0×3 | 0×8);
return v.toString(16);
});
return guid;

}


This generates a session ID like : 3f58555c-d6f4-4b1e-ac2a-b89f5d173944

then Use web_js_run() function.
Save the above javascript code with .js extension in the script folder.
Add the script under Extra files via Add Files option
Go to RunTimeSettings -Preferences-Options-Web Javascript header-Enable running javascript code == change the value to Yes
Write the following function.the the result is stored in param1


Dynamic transaction names in Load runner | Dynamic Transaction names in Vugen | Dynamic transaction names with Iteration number in LR

Sometimes you may want to create transaction names on your own. These may be with iteration numbers or with parameter values which are present in the parameter file. I will show you an easy way to do this. follow here.

The transaction names should be used with lr_eval_String as below

lr_start_transaction(lr_eval_string("The script is now at the iteration number# {IterationNumber}"));

lr_end_transaction(lr_eval_string("
The script is now at the iteration number# {IterationNumber}"), LR_AUTO);

Please make sure the Tx names of Start and End should be same, You need to pass the same value in Start and End Transactions so try to use the below code. Here the sTransName is a variable which holds the value of transaction name

Action()
char sTransName[50];

sprintf(
sTransName,lr_eval_string("TransactionA_{IterationNumber}"));

lr_start_transaction(
sTransName);

lr_end_transaction(
sTransName,LR_AUTO);

 return 0; 
}