Posts Tagged ‘Quick Tip’

Quick Tip – Blank Parameters in LoadRunner

Posted on March 1st 2011 by Joel Deutscher

LoadRunner happily accepts blank parameters, it just that Vugens parameters screen doesn’t realise it yet. Web searches show this being a problem for people as far back as 2008 and there are all kinds of solutions posted.

The blank parameter in notepad

Even though our blank parameter does not show up in Vugen parameter window, it is recognised.

And heres your blank parameter.

Nothing new here, though for me, it was more of a problem than a solution. I was caught out with two blank lines at the end of a parameter file. When editing in notepad, be sure to only have one blank line at the end of your parameter files. The single blank newline must be there, as its used as an end of file delimeter, and is not used as a parameter.

Dynamic Parameter Names in LoadRunner

Posted on January 4th 2011 by Joel Deutscher

Occasionally, you might want to perform the same action multiple times with different parameters. While you should be very carefull with this type of scripting, the following is a basic example of how to do this in LoadRunner.

The following script will perform three searches on google.com.au using three different parameters.

Action()
{
	int i;
	char temp[10];

	// Progress Through 3 Client IDs stored in {Param_1}, {Param_2} and {Param_3}
	for(i=1;i<4;i++) {
		sprintf(temp,"{Param_%d}",i );
		lr_save_string(lr_eval_string(temp), "Param_Value");
		lr_start_transaction("Search");

		// Extract Variables
		web_reg_save_param("Number_of_Results", "LB=About ", "RB= results", LAST);

		// Validate Content
		web_reg_find("Text=", LAST);

		web_url("search", 
			"URL=http://www.google.com.au/#hl=en&q={Param_Value}", 
			"Resource=0", 
			"RecContentType=text/html", 
			"Referer=", 
			"Snapshot=t1.inf", 
			"Mode=HTML", 
			LAST);
 
		lr_end_transaction("Search", LR_AUTO);
	}
	return 0;
}

Quick Tip – Validating Authentication Test Data in LoadRunner

Posted on October 31st 2010 by Joel Deutscher

LoginHere is a familiar situation. Thousands of potential accounts for use in performance testing, some of which work, some don’t. In this example, it’s the login credentials. This usually requires you to run through your test data one by one to see which accounts work, and which don’t, removing the accounts that error. By turning off HTTP redirects, you can speed up this process significantly.

This example script is a minimalist way of checking the data in a fairly quick way, without the burden of actually loading the pages. All you need to know is the URL that you are redirected to on successful login (or failure). In this example, the user is redirected to /dashboard.php on successful login.

// Disable HTTP Redirects to time Authentication
web_set_option("MaxRedirectionDepth", "0", LAST);

// Find Authenticated URL
web_reg_save_param("redirect_url", "LB=Location: ", "RB=\r\n", "Search=Headers", LAST);

web_submit_data("web_submit_data",
	"Action=http://www.headwired.com/login.php",
	"Method=POST",
	"TargetFrame=",
	"Referer=https://www.headwired.com/login.php",
	"Snapshot=t3.inf",
	ITEMDATA,
	"Name=username", "Value={INPUT_USERNAME}", ENDITEM,
	"Name=password", "Value={INPUT_PASSWORD}", ENDITEM,
	LAST);

if(!strcmp(lr_eval_string("{redirect_url}"),"https://www.headwired.com/dashboard.php")) {
	// Login Successful
	lr_output_message(lr_eval_string("Login Successful - {INPUT_USERNAME},{INPUT_PASSWORD}"));
}

Some of you may want to write the valid and invalid accounts to a file, yet for a once off execution, this method suits me just fine.

Fix Slow VuGen Replay?

Posted on October 8th 2010 by Joel Deutscher

StopwatchQuick tip: If you find VuGen is running slowly, it’s probably because you have the parameters data file open.

How much slower you ask? On a longer script I saw run-time drop from 415.8620 seconds to 50.2816 seconds

The good news is, closing the parameters file provides an instant boost of speed.

Timing HTTP Redirects in LoadRunner

Posted on September 29th 2010 by Joel Deutscher

One of the most commonly misscripted elements in performance testing is web authentication. I’m not talking about integrated authentication like SPNEGO, I’m talking about a simple HTTP POST with authentication details followed by the sites authenticated home page. The problem is that the user experiences a two step process.

User Login

In reality the process is actually 3 steps, with the middle step is transparent to the user. Because it is transparent, tools like LoadRunner will attempt to represent the end-user experience and record only two steps. In most cases, this is the desired end-result. The following diagram shows the three steps that occur.

Web Authentication

The issue with recording Logon like this, is that it does not allow you to separate the authentication time from the loading time of the subsequent page. Its a simple process to separate the timing of the authentication and the subsequent page load, and the following code snippet shows you how to do it in LoadRunner.

Action() {
	lr_start_transaction("Open_Logon_Page");

	// Validate Logon Page
	web_reg_find("Text=Lost your password?", LAST);

	// Open Logon Page
	web_url("logon_page",
                "URL=http://www.headwired.com/login.php",
                "TargetFrame=",
                "Resource=0",
                "RecContentType=text/html",
                "Snapshot=t1.inf",
                "Mode=HTML",
                LAST); 

	lr_end_transaction("Open_Logon_Page", LR_AUTO);

	// Disable HTTP Redirects to time Authentication
        web_set_option("MaxRedirectionDepth", "0", LAST);

	lr_start_transaction("Logon");
	lr_start_sub_transaction("Authenticate", "Logon");

	// Find Authenticated URL
	web_reg_save_param("redirect_url", "LB/ic=Location: ", "RB=\r\n", "Search=Headers", LAST);

	// Submit Authentication
	web_submit_data("web_submit_data",
                "Action=http://www.headwired.com/login.php",
		"Method=POST",
		"TargetFrame=",
		"Referer=",
		ITEMDATA,
		"Name=log", "Value={USERNAME}", ENDITEM,
		"Name=pwd", "Value={PASSWORD}", ENDITEM,
		"Name=redirect_to", "Value=http://www.headwired.com/dashboard/", ENDITEM,
		"Name=testcookie", "Value=1", ENDITEM,
		"Name=wp-submit", "Value=Log In", ENDITEM,
		LAST);

	lr_end_sub_transaction("Authenticate", LR_AUTO);

        // Enable HTTP Redirects to time Authentication
        web_set_option("MaxRedirectionDepth", "10", LAST);

	lr_start_sub_transaction("Authenticated_Page", "Logon");

	// Verify Authenticated Page
	web_reg_find("Text=Dashboard", LAST);

	web_url("authenticated_page",
                "URL={redirect_url}",
                "TargetFrame=",
                "Resource=0",
                "RecContentType=text/html",
                "Snapshot=t1.inf",
                "Mode=HTML",
                LAST); 

	lr_end_sub_transaction("Authenticated_Page", LR_AUTO);
	lr_end_transaction("Logon", LR_AUTO);

         return 0; 
}