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.

	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");

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

		// Validate Content
		web_reg_find("Text={Param_Value} - Google Search", LAST);

		lr_end_transaction("Search", LR_AUTO);
	return 0;

About the Author

Joel Deutscher is an experienced performance test consultant, passionate about continuous improvement. Joel works with Planit's Technical Testing Services as a Principal Consultant in Sydney, Australia. You can read more about Joel on LinkedIn.

Comments are closed.