How to Automate Api using Postman

Posted By : Sana Khan | 31-May-2021

 Postman is a very excellent API testing tool for developers, QA’s . Its UI allows you to easily send HTTP requests and see responses, apart from this it’s also a great automation tool.The Postman test Sandbox contains several useful libraries, functions and objects for testing the scenarios.
To check whether the response status code is 200 ||201 or not.
We can write our test cases using javascript.
pm.test("Status code is 200", function () {
   pm.response.to.have.status(200);
});

If you want to check the response there will be one tab called as test results there you can check your  results which will be executed after the request finishes.

If you want to run all your APIs in a single shot, there is an option, there is a button called runner in the top left corner always you can click that, select your collection and click run.

Let’s automate the Login API through Postman

1.Open Postman Application and create your apis collection.

2.
Then make your request to API by passing the correct credentials.

3. Now click on the Send button to see the response.

4.We will use access_token value and would not need to copy and paste the access_token value for each API.


5. Also, we can create the variable for host_name, protocol etc so that there will be no   need to write the protocol and host_name for each API, instead we can use the variable.

6.This is the important aspect is to check for correct Response/Status Code and the Response Time for each API.

7.You can check the value of access_token is set in the environment variable as expected.

8.Along with this in  TestResults tab you can check if the assertions you wrote have been passed or failed.

 

 

 

  

Related Tags

About Author

Author Image
Sana Khan

Sana is a highly experienced QA professional with expertise in manual, API, and performance testing. With a solid foundation in testing methodologies, she has effectively executed numerous testing projects, resulting in the delivery of high-quality software. Sana has also ventured into API automation, utilizing her skills to develop automated testing frameworks and optimize the testing process. She manages a team of 5 members and enjoys exploring new technologies and testing tools. Her contributions have been instrumental in the success of multiple projects, namely Oodles Dashboard and Oodles.com.

Request for Proposal

Name is required

Comment is required

Sending message..