What is Postman Automation?
Last Updated :
06 Feb, 2022
Postman is a cutting-edge Automation tool, which can be used for API testing, Automated Unit testing, and Integrated testing. The automation uses inherent functions provided inside Postman as well as allows usage of external JS library. Through Postman Runner functionality this feature can be used. This functionality allows us to create a Postman collection of any number of APIs which helps the Testing team to achieve faster and more efficient test results. The Postman Automation is pretty simple, due to the various inherent functionalities. Let’s see an example of simple automation.
In this demo request, the API is sent to the URL to generate an OTP, which resembles the basic login page of every modern web application.
Then the next API would be to validate the OTP, which goes like this
Here we are assuming the OTP to be 111111. Now, how to automate these, so that postman runs these 2 APIs in sequence and uses the right values. There are 2 Primary options available in Postman as Pre-Request Script and Tests. The major difference between those is that in the case Pre-Request Script the script is compiled before sending the request and in the case of Tests it is compiled after the response is received. For example, in this case for testing purposes, we can add a Pre-Request Script such that It will Create a new value for the “requesttime” field every time before running.
As we will further explore, we need to create a variable called request time/ (or any of your choice) which value will be populated by the Postman Script. These values will be stored in the environment variables collection available in the Postman application. Similarly, we can automate the user id field by using a random function provided by Postman such as:
Now, this function “$randomExampleEmail” will create random email ids every time the request is run. Hence making the process faster and more efficient than manually inputting data. Let us suppose the next API is meant to create a policy group such as:
As You can see in the response a policy is generated successfully, and now this value is now to be used in other APIs as variables or in the URL value of other APIs too such as:
Now for the {{Policygroupid}} variable to use the value generated in the previous API response we need to add a few lines of JS script. This can be done in many ways, for example:
Now, this snippet will search through the response API and look for the Id, after finding which it will store the same value in a variable called {{policygroupid}} (or any chosen name), making the whole process run with a single click.
Similar Reads
What is Low Code Automation Testing? Low-code test automation is a way of automating software tests without needing a lot of coding knowledge. It uses tools that offer easy-to-use visual interfaces, drag-and-drop features, and ready-made components, so even people with little coding experience can create and run automated tests. This m
11 min read
What is Scriptless Test Automation? In the Faster process of the software development world, scriptless test automation is an best solution that simplifies test automation without requiring deep programming knowledge. As compared to traditional automation, where developers write complex code, scriptless automation enables testers incl
10 min read
Automating API Testing with Postman Testing the functionality, dependability, and performance of an API is known as API testing. API testing can be done automatically or manually. The technique of automating the execution of API tests with tools is known as automated API testing. This can save time and effort, as well as ensure that A
5 min read
Postman Navigation Postman is a popular tool that makes it easy for developers to test APIs. With all its powerful features, Postman can speed up your API development process.In this guide, we will see the main parts of Postman's interface, so you can quickly become comfortable with the Postman Interface.Read More: Po
8 min read
Automation and its Types Just look at a scenario where we want to submit our electricity bill in normal case what we do, we go to the electricity center and fill the form and then submit our bill in this situation the complete task is done by a human. But in our day to day life we don't have that much time to do these task
2 min read