LoadRunner Transactions, Text and Image Checks, Comments and Rendezvous Points

Introduction to basic enhancements of VuGen Script:

In the last two tutorials, we worked on handling data in a VuGen script (Correlation and Parameterization).

In this LoadRunner tutorial, we will see the other basic enhancements (listed below) that are required for our script:

  1. Transactions – To measure rate and response time of the user actions.
  2. Text and Image checks – To ensure that the response returned is correct.
  3. Comments
  4. Rendezvous points – To make Vusers perform a task simultaneously.

transactions, text and image checks, comments and rendezvous points

Transactions in VuGen Script

The mere replay of performance scripts will only put a load on the application but does not measure anything. The end goal of any performance script is to inject load and measure the rate and response time of user actions on the application.

For Example, how much time a product search took when 100 users are on the application, how many reports are generated in a time of say 15 minutes and so on. To measure these, we have to insert transactions in a VuGen script (after the test, we can see the rate and response time of these transactions in the results).

‘A transaction is an end to end measurement of a user action (or a group of user actions) on an application’.

Transactions can be inserted in two ways:

  1. During Recording
  2. After Recording (where we manually insert the transaction functions in the script)

Let us insert transaction for the ‘Login’ user action on our ‘Web Tours’ application.

In our first tutorial, we saw how to record user actions. While recording, after entering the ‘Username‘and ‘Password’ on the Login page, just before clicking on ‘Login’ button, click on ‘Insert Start Transaction’ icon on the floating recording bar.

1.During recording

VuGen prompts for transaction name. Enter any meaningful name. We have given ‘Login’ here but it is a good practice to following a convention like this (transaction number, Scenario name, user action etc.): 01_WebTours_Launch 02_WebTours_Login (and so on).

2.VuGen prompts for transaction name

Now click on the Login button.

3.Now click on the Login button

Once we reach the homepage (main page), click on the ‘Insert End Transaction’ icon on the floating recording bar.

4.click on the ‘Insert End Transaction’ icon on the floating recording bar.

Select the transaction that we want to end (‘Login’ transaction here).

5. ‘Login’ transaction that we want to end

Stop the recording and see the generated script. We can see that transaction start and transaction end functions are inserted into the script (highlighted in yellow) and all the request(s) corresponding to the ‘Login’ user action are enclosed in between these functions.

lr_start_transaction("Login");

web_submit_data("login.pl",
"Action=http://127.0.0.1:1080/cgi-bin/login.pl",
"Method=POST",
"TargetFrame=",
"RecContentType=text/html",
"Referer=http://127.0.0.1:1080/cgi-bin/nav.pl?in=home",
"Snapshot=t3.inf",
"Mode=HTML",
ITEMDATA,
"Name=userSession", "Value=123530.624949372zDftVAzpfcAiDDDDDiVctpzDQVcf", ENDITEM,
"Name=username", "Value=jojo", ENDITEM,
"Name=password", "Value=bean", ENDITEM,
"Name=JSFormSubmit", "Value=off", ENDITEM,
"Name=login.x", "Value=69", ENDITEM,
"Name=login.y", "Value=8", ENDITEM,
LAST);

lr_end_transaction("Login",LR_AUTO);

The syntax of the ‘transaction start’ and ‘transaction end’ functions is pretty simple. Both have transaction name as the first argument. The ‘end transaction’ function has one more attribute – ‘LR_AUTO’, this instructs VuGen to Pass or Fail a transaction automatically (instead of us explicitly specifying a condition for a pass or fail).

If the load runner encounters any errors in executing requests within a transaction then it fails the transaction otherwise it passes the transaction.

Text and Image Checks in VuGen Script

Text checks are used to verify if the response returned for the request is correct or not. In the ‘Correlation’ tutorial, we saw that sometimes VuGen may not show any error but the returned response may not be the correct one. So, to ensure that the response is correct, we use text checks.

For Example, when we login into the web Tours application, we go to home page. Let’s verify in the script that we are getting the correct response (homepage) or not when we log in.

To do this, we have to identify some text in the response (homepage here) which can say if the response is correct or not. ‘Welcome’ is one such text.

6.Text and Image Checks

For text check, we use ‘web_reg_find’ function just before the request.

The syntax of this function is:

web_reg_find(“Text=”,”SaveCount=”,”Fail=”,LAST);

Here we have three attributes (refer VuGen help to get the complete list of attributes):

‘Text’- Used to specify what text to search for.

‘SaveCount’ – Saves the number of occurrences of the specified text into a parameter that we specify.

‘Fail’ – Takes one of the two values -‘Found’ and ‘NotFound’ and fails the script accordingly.

So the function, web_reg_find(“Text=Welcome”,”SaveCount=WelcomeCount”,”Fail=NotFound”, LAST) searches for the text ‘Welcome’ in the response and saves the number of occurrences into the parameter ‘WelcomeCount’ (and fails the script if the text is not found).

The script looks like this:

web_reg_find("Text=Welcome","SaveCount=WelcomeCount","Fail=NotFound",LAST);
web_submit_data("login.pl",
"Action=http://127.0.0.1:1080/cgi-bin/login.pl",
"Method=POST",
"TargetFrame=body",
"RecContentType=text/html",
"Referer=http://127.0.0.1:1080/cgi-bin/nav.pl?in=home",
"Snapshot=t2.inf",
"Mode=HTML",
ITEMDATA,
"Name=userSession", "Value=123531.149939247zDftVDDpfcfDiVctpiAVVf", ENDITEM,
"Name=username", "Value=jojo", ENDITEM,
"Name=password", "Value=bean", ENDITEM,
"Name=JSFormSubmit", "Value=off", ENDITEM,
"Name=login.x", "Value=66", ENDITEM,
"Name=login.y", "Value=12", ENDITEM,
LAST);

Now if we replay the script, we will get an error for the login request (see in the relay log) because VuGen did not find the text that we specified, in the response. This is because we did not get the correct home page (as shown in the ‘run-time viewer’).

7.if we replay the script, we will get an error for the login request

Now let’s correct our script (correlate the userSession) and replay the script again.


 web_reg_find("Text=Welcome","SaveCount=WelcomeCount","Fail=NotFound",LAST);

web_submit_data("login.pl", 
"Action=http://127.0.0.1:1080/cgi-bin/login.pl", 
"Method=POST", 
"TargetFrame=body", 
"RecContentType=text/html", 
"Referer=http://127.0.0.1:1080/cgi-bin/nav.pl?in=home", 
"Snapshot=t2.inf", 
"Mode=HTML", 
ITEMDATA, 
"Name=userSession", "Value={corUserSession}", ENDITEM, 
"Name=username", "Value=jojo", ENDITEM, 
"Name=password", "Value=bean", ENDITEM, 
"Name=JSFormSubmit", "Value=off", ENDITEM, 
"Name=login.x", "Value=66", ENDITEM, 
"Name=login.y", "Value=12", ENDITEM, 
LAST);

This time we do not see any error in the replay log but see a message that our text check was successful. So we got the correct response this time (as it is corroborated by the ‘runtime viewer’).

8.correct our script (correlate the userSession) and replay the script again.

We can combine text checks with transactions and make VuGen pass a transaction if the text check is successful and fail a transaction if a text check is failed.

This is shown below:

lr_start_transaction("Login");
web_reg_find("Text=Welcome","SaveCount=WelcomeCount",LAST);

web_submit_data("login.pl", 
"Action=http://127.0.0.1:1080/cgi-bin/login.pl", 
"Method=POST", 
"TargetFrame=body", 
"RecContentType=text/html", 
"Referer=http://127.0.0.1:1080/cgi-bin/nav.pl?in=home", 
"Snapshot=t2.inf", 
"Mode=HTML", 
ITEMDATA, 
"Name=userSession", "Value={corUserSession}", ENDITEM, 
"Name=username", "Value=jojo", ENDITEM, 
"Name=password", "Value=bean", ENDITEM, 
"Name=JSFormSubmit", "Value=off", ENDITEM, 
"Name=login.x", "Value=66", ENDITEM, 
"Name=login.y", "Value=12", ENDITEM, 
LAST);

if(atoi(lr_eval_string("{WelcomeCount}"))>0)

{
lr_end_transaction("Login",LR_PASS);
}

else
{
lr_end_transaction("Login",LR_FAIL);
}

We have used ‘if statement’ here with ‘SaveCount’ attribute. The ‘WelcomeCount’ parameter (which saves the number of occurrences of the text) is used as a condition to pass/fail the transaction. ‘LR_PASS’ and ‘LR_FAIL’ attributes of transaction functions are used to explicitly pass and fail (respectively) a transaction.

Note: We used two new functions here – ‘atoi’ and ‘lr_eval_string’. We shall talk about these functions later.

Some more information on the combination of ‘web_reg_find’ function attributes:

#1) If only ‘Text’ attribute is used

Example: web_reg_find(“Text=Welcome”,LAST) –

VuGen searches for the text and fails the script if the search is unsuccessful.

#2) If only ‘Text’ and ‘SaveCount’ attributes are used –

Example: web_reg_find(“Text=Welcome”,”SaveCount=WelcomeCount”, LAST) – VuGen searches for the text and saves the number of occurrences (even if it is zero) into the specified parameter (does not fail the script if the search is unsuccessful).

#3) If only ‘Text’ and ‘Fail’ attributes are used –

Example: web_reg_find(“Text=Welcome”,”Fail=NotFound”, LAST) – VuGen searches for the text and fails the script if the text is found/not found.

Text checks can also be inserted during recording using the ‘Insert text check’ icon on the floating recording bar. This will insert the same ‘web_reg_find’ function into the script.

9.‘Insert text check’ icon

But it is better that we insert this function manually as we will have better control mainly on the attributes.

We have understood text check clearly, now let’s go to image check.

Image check is used to verify the presence of a specified image in a response. ‘web_image_check’ function is used for image check. This function has to be put after the request (in the response of which we are expecting the image).

Example of this function:

web_image_check(“Image”,”Src=/WebTours/images/flights.gif”,LAST)

Where the first attribute is any meaningful name and the second attribute (‘Src’) is the image name/link (refer VuGen help to get the complete list of attributes).

Comments in VuGen Script

Comments in a VuGen script can be entered during recording and also manually after the script is recorded.

During recording, click on the ‘Insert Comment’ icon on the floating recording bar.

10.‘Insert Comment’ icon

Enter the comment (say ‘Login’ here).

11.Enter the comment

After recording, we can see the comments in the script as shown below.

/* Login */

web_submit_data("login.pl", 
"Action=http://127.0.0.1:1080/cgi-bin/login.pl", 
"Method=POST", 
"TargetFrame=body", 
"RecContentType=text/html", 
"Referer=http://127.0.0.1:1080/cgi-bin/nav.pl?in=home", 
"Snapshot=t6.inf", 
"Mode=HTML",

In VuGen, a single line can be commented by just putting ‘//’ before the line as shown below:

// web_add_cookie("SRCHD=AF=IESS3N; DOMAIN=www.bing.com");

web_add_cookie("SRCHUID=V=2&GUID=89730C3AA700412BAB917005DE9F5F47&dmnchg=1; DOMAIN=www.bing.com");

web_add_cookie("SRCHUSR=DOB=20180312; DOMAIN=www.bing.com");

And multiple lines can be connected by putting ‘/*’ in the start and ‘*/’ in the end (as shown below)

/* 
web_add_cookie("SRCHD=AF=IESS3N; DOMAIN=www.bing.com");

web_add_cookie("SRCHUID=V=2&GUID=89730C3AA700412BAB917005DE9F5F47&dmnchg=1; DOMAIN=www.bing.com");

web_add_cookie("SRCHUSR=DOB=20180312; DOMAIN=www.bing.com"); 
*/

Note: In the examples shown above, we commented the cookie functions (web_add_cookie). We will talk about cookie functions later in this tutorial series.

It is a good practice to insert comments at each step during recording because it will help us to relate the requests in the script to the user actions on the application.

Rendezvous Point in VuGen Script

If we have a scenario where a larger number of users perform an action simultaneously on the application (like checking results) and if we have to simulate the same in our performance test, we can use a ‘Rendezvous point’.

A ‘Rendezvous point’ is a single and simple function in a VuGen script that instructs load runner (during a test with multiple users) to wait at a specified step in the script till all the Vusers (executing the script) come to that step so that subsequent request can be executed simultaneously.

The syntax for Rendezvous function is:

lr_rendezvous(“MeaningfulName”); 

This function can be inserted during recording and also manually after the script is recorded.

Suppose we want to put a simultaneous load on the payment step in our ‘Web Tours’ application. During recording at that step (before submitting the payment details ), click on the ‘Insert Rendezvous’ icon on the floating recording bar.

12.payment details

And enter the rendezvous point name (any meaningful name).

13.enter the rendezvous point name

After recording, we can see the rendezvous function in the script like this.

lr_rendezvous("Payment");

web_submit_data("reservations.pl_3",
"Action=http://127.0.0.1:1080/cgi-bin/reservations.pl",
"Method=POST",
"TargetFrame=",
"RecContentType=text/html",
"Referer=http://127.0.0.1:1080/cgi-bin/reservations.pl",
"Snapshot=t13.inf",
"Mode=HTML",
ITEMDATA,
"Name=firstName", "Value=Jojo", ENDITEM,
"Name=lastName", "Value=Bean", ENDITEM,
"Name=address1", "Value=1st Lane, Down Street", ENDITEM,
"Name=address2", "Value=567123", ENDITEM,
"Name=pass1", "Value=Jojo Bean", ENDITEM,
"Name=creditCard", "Value=123456789101", ENDITEM,
"Name=expDate", "Value=0520", ENDITEM,
"Name=oldCCOption", "Value=", ENDITEM,
"Name=numPassengers", "Value=1", ENDITEM,
"Name=seatType", "Value=Coach", ENDITEM,
"Name=seatPref", "Value=None", ENDITEM,
"Name=outboundFlight", "Value=020;338;05/03/2018", ENDITEM,
"Name=advanceDiscount", "Value=0", ENDITEM,
"Name=returnFlight", "Value=", ENDITEM,
"Name=JSFormSubmit", "Value=off", ENDITEM,
"Name=.cgifields", "Value=saveCC", ENDITEM,
"Name=buyFlights.x", "Value=63", ENDITEM,
"Name=buyFlights.y", "Value=12", ENDITEM,
LAST);

Now when we run this script with multiple users in Controller, the script will be executed by Vusers independently but Vusers will wait at this ‘Payment’ step till all (or some percentage of Vusers defined in Rendezvous policy) reach this step after which they perform this step simultaneously.

We will see more on the rendezvous policy (options) in the Controller tutorial.

Conclusion

Until now we have discussed Correlation and Parameterization in the previous tutorials and Transactions, Text/Image checks, Comments and Rendezvous points in this tutorial, we have also covered the most important script enhancement methods.

In our next tutorial, we will see some more scripting challenges along with the ways to handle them.

PREV Tutorial | NEXT Tutorial