Parameterization in Loadrunner examples

Welcome to parameterization in loadrunner examples ,in my previous post you learned Web Services scripting in Loadrunner,now in this post you will learn how to do parameterization for your test scripts in Virtual User Generator,in order to work with multiple test data to verify how your test scripts works correctly.

Parameterization in Loadrunner examples

Parameterization means Replacing hard coded values in the script with the test data is called Parameterization. Parameterization will helps to reduce script size & Avoid cache effect.Now let’s see below example to understand clearly to perform parameterization of test script in loadrunner.

I am using Web Services script to perform parameterization to understand clearly,you can use Web Applications but while working with Web Services you will learn more knowledge.Let’s see below example.

Web Service Request

 

Action()
{
		web_service_call( "StepName=CreateFlightOrder_101",
		"SOAPMethod=HPFlights_Service|FlightsServiceMethods|CreateFlightOrder",
		"ResponseParam=response",
		"Service=HPFlights_Service",
		"ExpectedResponse=SoapResult",
		"Snapshot=t1477723319.inf",
		BEGIN_ARGUMENTS,
		"xml:FlightOrder="
			"<FlightOrder>"
				"<Class>Economy</Class>"
				"<CustomerName>Rajesh kumar</CustomerName>"
				"<DepartureDate>2016-10-31</DepartureDate>"
				"<FlightNumber>1089</FlightNumber>"
				"<NumberOfTickets>1</NumberOfTickets>"
			"</FlightOrder>",
		END_ARGUMENTS,
		BEGIN_RESULT,
		"CreateFlightOrderResult/OrderNumber=Param_OrderNumber",
		"CreateFlightOrderResult/TotalPrice=Param_TotalPrice",
		END_RESULT,
		LAST);

return ;
}

 

For Above Create Flight Order request we are going to perform parameterization for Below tags/input arguments to complete test scenario for multiple iterations.

ALSO READ  How to Design a Goal Oriented Scenario

Flight Order

1.Class
2.Customer Name
3.DepartureDate
4.Flight Number
5.NumberOfTickets

 

"xml:FlightOrder="
"<FlightOrder>"
"<Class>Economy</Class>"
"<CustomerName>Rajesh kumar</CustomerName>"
"<DepartureDate>2016-10-31</DepartureDate>"
"<FlightNumber>1089</FlightNumber>"
"<NumberOfTickets>1</NumberOfTickets>"
"</FlightOrder>",

 

Why i have taken above input arguments means ,in order to create the Flight order you should require above input parameters to get response and i am taking just three records to do parameterization in loadrunner.

STEP 1:

1.Select the value i.e Economy in Class tag.
2.Right Click on Selected Value.
3.Click on Replace with Parameter – Create New Parameter

4.Enter Parameter Name as Class_name.
5.Click on Properties button.

6.Parameter Properties window will open.

STEP 2:

Now we need to create CSV file for test data please follow below steps to create CSV file.

1.Click on Browse button and go to your script directory path E:Loadrunner_TutorialsFlightService.

2.Select Files of Type as All Files and Enter File name as CreateFlightOrder.csv extension.

3.Click on Open Button,now in Parameter Properties window File path will shows as csv file.
4.Click on Create Table button and Click on OK button.

5.Now it will create Given Parameter Name as Column name in table and selected Value as Value in Row.

ALSO READ  Loadrunner Tips and Tricks to create a script

STEP 3:

1.Now it’s Time to Select some settings in Parameter Properties window for each columns to pick up Unique test data for each iteration.
2.Select Column name in Select Column tab – By Name as below screenshot and Select Next Row as Unique from drop down lists.

3.Click on Close button.
4.Click on OK button.
5.Click on No button on HP Virtual User Generator pop up.

STEP 4:

1.Now select second value i.e CustomerName tag value i.e Rajesh kumar.
2.Right Click on Selected Value.
3.Click on Replace with Parameter – Create New Parameter.
4.Enter Parameter Name as Cust_Name.
5.Click on Properties button.
6.Now Select CreateFlightOrder.csv file.
7.Click on Add Column,click on OK button.

8.Repeat same steps for DepartureDate,FlightNumber and NumberOfTickets,now your Parameter Properties window looks like below.

9.Click on SAVE button in VUGen window.
10.Now Test Script will looks as below with parameters.

 

Action()
{
lr_start_transaction("01_CreateFlight_Order");
web_service_call( "StepName=CreateFlightOrder_101",
"SOAPMethod=HPFlights_Service|FlightsServiceMethods|CreateFlightOrder",
"ResponseParam=response",
"Service=HPFlights_Service",
"ExpectedResponse=SoapResult",
"Snapshot=t1477723319.inf",
BEGIN_ARGUMENTS,
"xml:FlightOrder="
"<FlightOrder>"
"<Class>{Class_name}</Class>"
"<CustomerName>{Cust_Name}</CustomerName>"
"<DepartureDate>{Departure_Date}</DepartureDate>"
"<FlightNumber>{Flight_Number}</FlightNumber>"
"<NumberOfTickets>{No_Tickets}</NumberOfTickets>"
"</FlightOrder>",
END_ARGUMENTS,
BEGIN_RESULT,
"CreateFlightOrderResult/OrderNumber=Param_OrderNumber",
"CreateFlightOrderResult/TotalPrice=Param_TotalPrice",
END_RESULT,
LAST);
lr_end_transaction("01_CreateFlight_Order",LR_AUTO);

return ;
}

 

ALSO READ  Loadrunner Functions

 

STEP 5:

1.Now go to Test Script directory path to Edit CSV file E:Loadrunner_TutorialsFlightService.
2.Open Your CSV file with Notepad++ or Notepad,you can open/edit csv file data in Parameter tab of Virtual User Generator.
3.Enter your test data in csv file.Now your csv file will display as below.

4.Save your script in Vugen window.

STEP 6:

1.Now it’s time to change settings for Run Time settings.
2.Click on Run Time Settings in Solution Explorer.

3.In Run Time settings go to Run Login
4.Enter Number of Iterations to run ,as per CSV file 3 because 3 records i have inserted in CSV file.

5.Click on OK
6.Go to Log – Select Extended Log-Select All Check Boxes.

7.Click on OK button.

STEP 7:

Now Save your changes and Click on RUN icon in VUGen window.Your script execute for three time because Number of Iterations is 3 with unique test data.

Replay Summary

Replay Status

Test Results

I hope you understood the concept of Parameterization in loadrunner with above example,please share my post and provide your valuable comments,suggestions on this post.Thank you for reading.

Rajesh

Rajesh has over 8+ years of experience in Quality Assurance (Automation/ Manual). I've completed his B.Texh. He is an experienced software tester,work experience include working on tools like TestNG, Sikuli, Autoit, Selenium Builder and Appium, has worked on various projects from verticals like Retail, Insurance, Tolling and many more and passionate about designing Automation Frameworks that are effective and easy to maintain using Selenium Java.

Leave a Reply

Your email address will not be published. Required fields are marked *