Executing Tests on Cookies in Postman


We can execute Tests on Cookies in Postman. Once a request gets executed for an endpoint, a Response gets generated. Within a Response, the cookie information gets generated under the Cookies tab.

We can add Tests script around cookies and apply Assertions on them for verification. Test scripts are incorporated under the Tests tab. Let us add the below script to verify the value of cookie – Cookie_Postman.

pm.test("Verify Cookie value", function(){
pm.expect(pm.cookies.get('Cookie_Postman')).to.eql('value1')})

Send the Request. After the Response is received, navigate to the Tests tab. It shows the Assertion in our Test script failed as the expected value of the Cookie_Postman is value 1 but the actual value is cookie_Val.

Updated on: 03-Aug-2021

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements