Postman Tutorial For Automation

Why Automation and Postman?

Automation is the new standard crosswise over sectors. Automation, using postman in testing can improve and increase the depth and also extent of tests for a superior software quality. This blog will help you to understand the automated testing process and run postman in chrome. Also it helps to introduce API automation to your day by day QA processes for executing repeated test cases.

Need for Postman Automation-

Postman Automation is genuinely significant while testing products with an enormous number of integrations as well as successive releases. It is the definitive tool for API automation. The main goal of QA automation is to decrease the consolidated amount of effort required for manually re-testing of a product which is genuinely high. Also, for expulsion of the manual testing efforts that are invested in testing a set of functionalities frequently.

For example, Agile practices like continuous builds, the amount of time taken to receive feedback for a manual regression test with the new code is excessively high. API testing is also known as Integration testing. Integration testing focuses around verifying that the interactions of numerous small components can integrate together without issue. Since API tests bypass the UI, they tend to be quicker and substantially more viable than GUI tests. Hence, a great QA teams will make genuinely precise projections based on the current backlog and also the general information about the project and its architecture and use automation for regression test. So in the event that you are doing it in- house or deciding on product outsourcing, postman automation turns out to be progressively significant as it automates the whole testing process and also saves important time and resources.

Insights into Postman Tutorial for API Automation-

Postman a Chrome application is for interacting with HTTP APIs. Postman allows user to automate test cases in javascript with notable highlights like write test suites, build requests that can contain dynamic parameters, pass data between requests, and so on. For approval of API, on getting a response, Postman validates the response as described in the test contents. This is performed under “Tests” section. Most intriguing part is a JSON response can be parsed into an array and then the elements can be accessed by index and esteem or even be iterated also. The primary advantage of utilizing postman is that user doesn’t have to create a full JSON request programmatically dissimilar to other automation API frameworks to put assert on it. Postman flawlessly design them and helps user directly define test cases.

Tools/Dependency to get started –

1. Postman

2. Node

3. Newman

Introduction to Newman-

Newman is Postman’s collection runner engine that sends API requests, gets the response and also afterward runs your test against the response. It resembles postman’s command line companion. It is extensible. Hence can be integrated into continuous integration servers and build systems.

Benefits of using Newman-

  1. Using Newman it is easy to run a collection of tests using command line
  2. It gives ability to run a collection of tests written in postman right from within most build tools.
  3. It allows to generate and store report directly from command line
    Installing Newman.

Postman tutorial for Newman integration-

Newman is a companion tool for postman that runs Collections from the command line. Newman keeps up feature parity with Postman and enables user to run collections likewise they are executed inside the collection runner in the Postman application.


In this Postman tutorial for Automation we are additionally going to cover variables. There are two kinds of variables – global and environment. Global variables are for all collections though the environment variables which are defined for a particular set of collections according to the environment which can be chosen from a drop-down or no environment can be chosen.

When defined variables can be used in request with format encompassed by curly brackets:  {{VARIABLE_NAME}}

The global variables are variables which can we consumed by any collection. So for any data that is accessible for all collections, we define them as global variables. The data defined for a specific environment is called as Environmental variable. We can choose any one environment at a time for a collection or no environment according to choice.

• In Postman, at the top right section, click on (*) icon.

• Now click on MANAGE ENVIRONMENTS (refer the image below)

All the existing environments will be listed under Manage Environments.

• To create an environment, click on Add button at the bottom of the pop-up 

and enter a new Environment.

• To add a global variable, click on the Globals button listed at the bottom of the pop-up.

• For setting a new variable (global and environment), we need to define the New key and Value.

Pre-Request Script-

Next in this Postman Tutorial is Pre- Request Scripts. As the name recommends will run before Tests. Postman allows users to perform specific JavaScript coding to control the data being sent alongside the request. We can write these scripts in Tests section also however it is a decent practice to separate these scripts in pre-request section as it will be executed before Tests scripts. Here we can set Global and Environment Variable dynamically also.

Copy- Paste the below code in Pre- request Script section in Postman :-

postman.setGlobalVariable(“Token”, “MyDemoToken”);

postman.setEnvironmentVariable(“MyKey”, “MyDemoKey”);


console.log(“Global Variable = “+postman.getGlobalVariable(“Token”));

console.log(“Environment Variable = “+postman.getEnvironmentVariable(“MyKey”));

  • Select an environment from the dropdown located at the top right section of the screen.
  • Click on “Send”
  • Now go to Global and Environment variable section.
  • Observe that keys have been set dynamically by the script.

To see console output of script use below steps-

1. Type chrome://flags/#debug-packed-apps in the URL bar in your Chrome browser window.

2. Look out for “Debugging for packed apps”.

3. Enable the setting.

4. Click on Relaunch Now once the setting is enabled.

5. Type chrome://inspect/#apps in the URL bar and then click “inspect”

Note :- To get the console output of collection runner, click on the Inspect link of the respective instance from Apps section.

Postman Tutorial for Best Practices of Automation testing-

1. Use trim function if data is retrieved as String from the CSV file.

2. Add your pre- request data in Pre- request Script section.

3. Use chrome dev console for debugging.

4. Always check the length of an array for a test case. It will safeguard the script from failing due to javascript exception

Example :-



tests[“Response should have last name of gob as bluth” ] =[1].last_name === “bluth”;

Advantages of using Postman-

1. If API is updated and test is run in postman, it gives sign of failure. The API would then be updated for right results.

2. Postman can be used for performance testing of API.

3. Postman can be used to perform load testing at scheduled time and record the status

4. As the API’s are automated using postman there is minimum human involvement.

Final Words-

We hope that this Postman Tutorial will be helpful for you. We can conclude that API automation is important task in custom software development. Postman tool caters best to all requirements needed for an efficient API testing process. You can try it to get a stronghold on API’s.

Are you looking for a web development to boost your business? Solace experts are there to help you using new trends. Develop you website with a Solace for more efficiency. Contact us for any web development.