REST API Services Testing using loadrunner

REST API Services Testing using loadrunner,rest api services uses web http/html protocol while creating REST API Services scripts using virtual user generator,which is a loadrunner component.Most of the companies are using REST API services in order provide better security in customer data,fast execution for communication between
multiple applications.

Please read Complete Loadrunner Tutorial

REST API Services Testing using loadrunner

In this post we will create REST API Services script in Virtual User Generator i.e VUGen,Please follow below steps to create script for REST API services using VUgen.

Steps:

1.REST API URL
2.Which Protocol should use
3.What is the input parameters
4.What is the output Response
5.Content- Type
6.Method – GET,POST,DELETE etc.

ALSO READ  lr_xml_find function example

Once you know all above details then it is easy to create the script with the help of below simple syntax ,plesae use below syntax for all rest api services for load testing.

web_custom_request("Card_validation",
"URL=http://ipaddress:portno/cardApi/api1/card/linkcard",
"Method=POST",
"Resource=0",
"EncType=application/json",
"Mode=HTTP",
"Body="Body={"cardNo":"9898989898989898","cardType":"CreditCard","MobileNo":"1111111111"}",
LAST);

CODE Explanation:

As you see above code i have used web_custom_request() function which is allow users to create custom HTTP request with any useful method(POST,GET,DELETE etc)

1.Card_validation : Request Name

List of Resources:

URL
Method
Resource
EncType
Mode
Body

Method=POST:

As based on above resources we will create REST API Services scripting as you see “Method=POST” which is posting the values to database,in case you want to get the details from the database then you can use “Method=GET“.

ALSO READ  Web Services Scripting Using Loadrunner

EncType=application/json:

As i have used application/json because content-Type of REST API service is developed with Media Type,as REST API Services has below Media Types,those are

1.application/json
2.application/xml
3.text/xml
4.multipart/form-data
5.multipart/mixed

Most of the REST API services are developed with application/json,application/xml and text/xml media types,this one provided by developer.

Mode=HTTP:

As i mention in first paragraph REST API service is developed with HTTP protocol for data transfering to multiple systems.While creating the REST API script you need to select
Web-HTTP/HTML protocol.

Body:

Body resource which contains input request parameters as i written in above script.The main rest api input request is as below

{
"cardNo":"9898989898989898",
"cardType":"CreditCard",
"MobileNo":"1111111111"
}

You can write above input request into below code in order to mention in Body resource.Please check below code.

"Body={"cardNo":"9898989898989898","cardType":"CreditCard","MobileNo":"1111111111"}"

LAST:

LAST argument which tells a market which indicates the end of the field list.This total web_custom_request() function returns LR_FAIL(1) or LR_PASS(0) on successful and on failure of web_custom_request()
function execution.

ALSO READ  Loadrunner Tips and Tricks to create a script

Parameterization:

We can perform Parameterization for input parameters as we mention in Body ,Please read Correlation in loadrunner post,you will get clear idea about manual and automatic correlation for any script whether it could be a web request,rest api or Web-Services.

Thank you for reading,i hope you got good knowledge about REST API Services Testing using loadrunner,please provide your valuable comments and suggestions on this post.

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. Abhishek has worked on various projects from verticals like Retail, Health 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 *