Test automation of APIs using Postman

Test automation of APIs using Postman 27 Jun,2017

API is Application Programming Interface. It is used to establish communication and data exchange between two software systems. A software system implementing an API consists of various functions and sub-routines which can be executed by another software system. API testing is totally different from GUI testing. It basically concentrates on the business logic layer of the software architecture. In API Testing, you use software to send calls to the API, get output, and note down the system’s response.

API Architecture


API calls collection includes mainly two things:

1. HTTP headers: HTTP headers are always dependent on your application.

i) Authorization: A token included with requests to identify the requester. This header has to be included in all requests other than the login request.

ii) Content-Type: A standard MIME type describes the format of object data.
Content type in most of the requests and responses will be application/json.

2. HTTP Request: There are mainly four types of requests.

i) POST– Used to Create or Update data

ii) PUT- Used to Update data

iii) GET- Used to Retrieve data

iv) DELETE– Used to Delete data

What is Postman?


Postman is used to fire requests to an API. It is available as add-in on Chrome and also available for Mac application.  It is very fast in response and also light weight which puts no impact on browser performance. Tests can be created with verifications for certain conditions on the response. With Postman, you can create different kinds of HTTP requests such as GET, POST, PUT, PATCH and DELETE. It also provides supports for adding headers in the requests. It’s a very convenient API tool with very useful features.

How To Perform Automation Testing of APIs Using Postman?


Following criteria detailing the process, to perform automation software testing of APIs by using Postman:

* First, install ‘POSTMAN’ add on in Google Chrome.

* Open Postman.

* Click on ‘Create New Collection’ button, fill details and Click ‘Create’ button.

* Now go to newly created Collection and Create New Folder by selecting ‘Add Folder’ option of side menu bar.

* Now Click ‘+’ Button for opening new Tab.

* Now Fill URL, headers, Select Method (Get/POST/PATCH etc.), Body etc. and click ‘Send’. It will show the result in a response. It should return desired results. If there is a problem Please recheck every prerequisites and requirement.

* You can add desired assertions in a particular request in tests tab like:

           tests[“Check: Status code is 201”] = responseCode.code === 201;

* Now ‘Save as’ request by filling its Name, Folder Name, Description etc. It will show the request under your selected Folder/Collection.

* Now Click on Setting Environment Button (Setting Icon on Top right corner under Heart Icon) and select ‘Manage Environments’.

* Click on ‘Add’ Button, Enter Name for environments, Enter Keys and Values. Keys(Name of the variable like URL), Value(Value of Variable like: http://bugraptors.com/). Click ‘Add’. It will create environments.

* Now select newly created environments from DDL (Top right corner with setting Icon).

* Now use the variable as a requirement. Syntax to use is {{Key of variable}}.Like: {{URL}}. It will show variables in a list and you can select from there too. If the variable is accessible it will automatically convert it into orange color either it will reflect in Red color.

* Do the same process for all your APIs.

* Now you can run the whole collection or single folder by Clicking on ‘Runner’ (Top Left corner Button) or Click run from the submenu of the desired collection. It will open Runner Window. Select Collection/Folder, Select required environments, Fill iteration count (If you want to run it multiple times), Fill Delay, Choose Data File if required, and click ‘Start Test’. It will Give you result of every request.

* You can fetch Data from the response of a particular request and store that in variables. The syntax of it is like:

           var jsonData = JSON.parse(responseBody);

           postman.setEnvironmentVariable(“variable_key”, “variable_value”);

* For ‘report’ you have to install ‘Newman’ on your PC. It is command line tool that can generate the report by running POSTMAN collections.

* Now export Postman Collection by selecting Export from the left menu bar of the desired collection.

* Also, export the required environments on manage environments window from download icon button.

HarmanJeet Kaur Harman is an Automation Test Engineer at BugRaptors. She has expertise in Web & Mobile automation testing using Selenium WebDriver and Appium Tool. Professional in writing automating test scripts ,Data Driven Implementation , Keyword frameworks, Debugging, Executing and find issues in scripts.

Leave a Reply

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

Name field is required !

Related Posts

How To Use Ignore Annotation In JUnit?
Test automation of APIs using Postman

JUnit is an open source framework for Java programming language which is used for writing and running tests. This practice helps developers to discove...

Read More
Influence of emphasized automation in CI
Test automation of APIs using Postman

Software systems are an integral part of life from business applications to consumer products. Quality has become a major paradigm these days. Softwar...

Read More
Why To Choose HP UFT: Automation Testing Tool
Test automation of APIs using Postman

HP Unified Functional Testing is a functional testing tool that integrates the features of various other HP products (Quickest Professional, WinRunner...

Read More
Introduction to Ranorex: Components & Features
Test automation of APIs using Postman

Ranorex is a software testing tool that provides test automation for multiple environments, devices and software applications. It allows the users to ...

Read More

Popular Blogs

The Thought Process Of Non-Technical Person While Approaching For Selenium?
The Thought Process Of Non-Technical Person While Approaching For Selenium? Read More
How To Use Ignore Annotation In JUnit?
How To Use Ignore Annotation In JUnit? Read More
Why RTM(Requirement Traceability Matrix) Is Important In testing?
Why RTM(Requirement Traceability Matrix) Is Important In testing? Read More
Major Fascinating Features in iOS12 Enlisted for iOS Users
Major Fascinating Features in iOS12 Enlisted for iOS Users Read More
Augmented Reality Application Testing: Is It Really Worth Investing?
Augmented Reality Application Testing: Is It Really Worth Investing? Read More


Do you want to automate your web application?
contact us