How To Use Postman Features: Tips

Postman is a popular platform used for the development and testing of API. It is quick to learn and easy to use. It provides several cool features that aid QA in API testing. In this post, we will see how to use Postman features effectively.

1)How to monitor API health in Postman?

Postman monitor is a very cool feature that facilitates its users to schedule automated tests and monitor the health of API and send alerts to any test failures or system outages.

Click new–>Select Monitor–>Select Monitor Existing Collection–>Choose Collection

Provide basic details like Monitor name, Test Name, Email and Schedule run time and you are good to go.

Monitoring your API's

Once tests are executed, the results are available under the Monitor section and mail gets triggered.

Postman Features

2)How to handle Conditional Workflow in Postman?

Condition flow is used to give a subsequent request flow based on the condition. It’s basically an if-else condition, if this condition is met then execute this API, if not then execute this API.

The pre-request or test script can utilize the postman.setNextRequest argument. The runner defaults to linear execution and proceeds to the next request if postman.setNextRequest is absent.

if(yes)
{
Execute This
}
Else
{
Execute That
}
postman.setNextRequest("Req Name");
terminates execution

Refer below code for more understanding.

var customer = JSON.parse(responseBody);

if (customer.id === undefined) {
  // No customer was returned, so don't run the rest of the collection
  postman.setNextRequest(null);
}
else {
  // Save the customer ID to a Postman environment variable
  postman.setEnvironmentVariable("cust_id", customer.id);

  // The "Edit Customer" request uses the "cust_id" variable
  postman.setNextRequest('Edit Customer');
}

3)How to import Swagger Collection in Postman?

Swagger collection can be imported in postman by providing swagger documents’ URL and all documented APIs will be imported in a collection with all the provided information like Methods, headers, request body, and params.

Click on Import–>Go to Link–>Enter URL and Submit.

4)How to import Requests in Postman from Browser

Open Browser–>Navigate to site–>Open Network Tab–>Select request and right click–>import as Curl Request.

  1. Open postman.
  2. Click the import tab on the top left side.
  3. Select the raw test tab.
  4. Paste the raw text, then click continue.
  5. Confirm the name, format, and Import as
  6. If step 5. is correct, click import.

This automatically imports Curl into Postman.

5)How to generate API Documentation in Postman?

The documentation for your API is the primary source for explaining what is possible and how to get started. Postman automatically generates basic documentation for any collection we create.

Go To Collection–> Click on 3 dot menu–>View Documentation

Documentation is available. Users can publish it by clicking publish and share URL.

6)What is the cURL command in Postman?

Client URL or cURL is used for the transmission of data from the command line or shell script. We can import requests in Postman using cURL.

Open Postman –> Click import tab –> Choose the Raw text option and paste the cURL command –> Click Import

Postman will convert this cURL request into an HTTP request.

7)How to generate random test data in Postman?

Postman provides several built-in javascript libraries to generate test data. Some of the popularly known libraries are Faker.js and Moment.js.

Example:

randomName = {{$randomFirstName}}
randomDate = {{randomDateRecent}}

8)GraphQL support

Postman has built-in support to test GraphQl queries. Go to the Body tab and select the GraphQL radio button. Two sections are available. Put GraphQL Query in the query section and variable in GraphQL variable section.

Discover more from AutomationQaHub

Subscribe now to keep reading and get access to the full archive.

Continue reading