SlideShare a Scribd company logo
1 of 17
Postman API Scripts
Postman response assertions with JS scripts
Points to discuss
● Scripting in Postman
● Execution order of scripts
● Hierarchy of scripts
● Script globals, Scope
● Cred operations for local scope
● Cred operations for global scope
● Cred operations for collections scope
● Cred operations for env scope
● Dynamic variables & debugging
● Scripting with request and response data
Scripting in Postman
Scripting in Postman will help you to automate the process to test the output of
given REST API, HTTP API or SOAP API.
● Postman supports a powerful runtime platform “Node.js” that allows you to add dynamic behavior to
requests and collections.
● This allows you to write test suites, build requests that can contain dynamic parameters, pass data
between requests, and a lot more.
● We can add scripts to pre-request scripts tab and tests tab under request.
Execution order of scripts
As discussed, we can add script to automate testing in Pre-request script & tests tabs of request window.
Pre-request script associated with any request in postman
● Always execute before request is sent.
● Perform the operation and add variable or env variable to request if any.
Test script associated with any request in postman
● Always execute after request is sent.
Hierarchy of scripts
Pre-request script & tests script can be add into 3 levels.
Collections level
● A pre-request script associated with a collection will run prior to every request in the collection.
● A test script associated with a collection will run after every request in the collection.
Folder level
● A pre-request script associated with a folder will run prior to every request in the folder.
● A test script associated with a folder will run after every request in the folder.
Request level
● A pre-request script associated with a request will run before every request is sent.
● A test script associated with a request will run after to every request is sent.
Script globals, Scope
pm object
It is postman object which provides to functionality for testing your request and response data. The pm
object provides methods for accessing global, collection, and environment variables specifically, and
pm.variables methods for accessing variables at different scopes as well as setting local variables.
pm.variables: dictionary or associative variable of pm object for local scope
It helps to store variables with its value within request scope & access in request scope.
pm.globals: dictionary or associative variable of pm object for global scope
It helps to store variables with its value. This scope will use when it needs to pass variables to other
requests.
Script globals, Scope
pm.collectionVariables: dictionary or associative variable of pm object for collections scope
It is good alternative to global or environment variables and store credentials & pass to requests within
postman collection.
pm.environment: dictionary or associative variable of pm object for environment specific
Environment variables are tied to the selected environment(test, dev or production). It is good alternative
to global variables as they have a narrower scope. It can be used to storing environment specific
information, URLs, authentication credentials & passing data to other requests.
pm.iterationData: dictionary or associative variable of pm object for iteration only
It can be used during execution of iteration or multiple data-sets are needed.
Cred operation for local scope
1. Set or create variable to local scope or request scope itself: in this case, we will set scope named
variable with its value…
pm.variables.set(“scope”,”request”)
To store variable, it needs to provide key & value pair.
1. Get or read value of specific variable:
pm.variables.get(“scope”)
1. Check specific variable exists in local scope
pm.variables.has(“scope”)
Return value can be true or false
1. Delete specific variable from local scope
pm.variables.unset(“scope”)
Cred operation for Global scope
1. Set or create variable to global scope: in this case, we will set scope named variable with its value…
pm.globals.set(“scope”,”global”)
To store variable, it needs to provide key & value pair.
1. Get or read value of specific variable:
pm.globals.get(“scope”)
1. Check specific variable exists in global scope
pm.globals.has(“scope”)
Return value can be true or false
1. Delete specific variable from global scope
pm.globals.unset(“scope”)
1. Delete all variable from global scope
pm.globals.clear()
Cred operation for Collections scope
1. Set or create variable to collection(can be access in all requests of specific collections) scope: in this
case, we will set scope named variable with its value…
pm.collectionVariables.set(“scope”,”collection”)
To store variable, it needs to provide key & value pair.
1. Get or read value of specific variable:
pm.collectionVariables.get(“scope”)
1. Check specific variable exists in collection scope
pm.collectionVariables.has(“scope”)
Return value can be true or false
1. Delete specific variable from collection scope
pm.collectionVariables.unset(“scope”)
Cred operation for environment scope
1. Set or create variable to environment(can be access in all requests of specific environment) scope: in
this case, we will set scope named variable with its value…
pm.environment.set(“scope”,”env”)
To store variable, it needs to provide key & value pair.
1. Get or read value of specific variable:
pm.environment.get(“scope”)
1. Check specific variable exists in environment scope
pm.environment.has(“scope”)
Return value can be true or false
1. Delete specific variable from environment scope
pm.environment.unset(“scope”)
1. Delete all variable from global scope
pm.environment.clear()
Dynamic variables & Debugging
Postman provides the faker library to generate dynamic dummy data. We can generate random names,
addresses, email addresses, and much more. You can use these pre-defined variables multiple times to
return different values per request.
Dynamic variables’ values are generated at the time of execution and their names start with a $ symbol e.g.
$guid, $timestamp etc.
To use dynamic variables in pre-request or test scripts, you need to use pm.variables.replaceIn(), e.g.
pm.variables.replaceIn('{{$randomFirstName}}').
Common variables are:
$guid: A uuid-v4 style guid
$timestamp: The current UNIX timestamp in seconds
$isoTimestamp: The current ISO timestamp at zero UTC
$randomUUID: A random 36-character UUID
More reference: https://learning.postman.com/docs/writing-scripts/script-references/variables-list/
Dynamic variables & Debugging Continued...
To debugging in pre-request script or tests tab just use console.log. Let's take some examples of some code
snippets
1. To check variable in exists in local scope
console.log(pm.variables.has(“scope”)) //output will be true
1. To get the value of scope variable in local scope
console.log(pm.variables.get(“scope”)) // output will be request
Let’s define one variable with local scope and debugging value:
pm.variables.set(“scope”,”request”);
console.log(pm.variables.get(“scope”)) // output will be request
Let’s update the value of defined variable of local scope
pm.variables.set(“scope”,”updated request”);
console.log(pm.variables.get(“scope”)) // output will be updated request
Note: to check console window go to view menu from top→ show console
Scripting with request and response data
To send the request or get the response data or process the response data, postman scripts provides a
variety of methods like
pm.request : it provides the pre-defined variables & methods to send or perform ops on postman request
Properties & methods of pm.request
● pm.request.url : request url
● pm.request.headers: list of request headers which stores various data in key, value regarding the
requests.
● pm.request.method : HTTP request like PUT, GET, DELETE, POST, HEAD etc.
pm.response: it provides the pre-defined variables & method to work or get the data of returned data of
sent request.
Properties & methods of pm.response
● pm.response.code : HTTP response code which can be in range of 100-599
Scripting with request and response data
Variables of pm.response
● pm.response.status : HTTP response text string
● pm.response.headers: list of headers returned by sent request
● pm.response.responseTime : The time the response took to receive in milliseconds
● pm.response.responseSize : The size of the response received
● pm.response.text() : Get the text of response
● pm.response.json() : Get the text of response in json format
pm.info : it provides the information related to request including event name, ID, iteration count etc.
Properties & methods of pm.info
● pm.request.eventName: the event which can be pre-request or tests depending on where the script is
executing within the request.
● pm.info.iteration : The total number of iterations that are scheduled to run
● pm.info.requestName: The saved name of the request running
● pm.info.requestId: A unique id of request in GUID format
Scripting with request and response data
pm.cookies : A objects provide the access the list of cookies associated with request.
Properties & methods of pm.cookies
● pm.cookies.has(cookiename): to check whether the cookie exists in request or not. Just provide the
name cookie as parameter in method.
● pm.cookies.get(cookiename) : To get the value of specified cookie as parameter
● pm.cookies.toObject(): To get a copy of cookies with values in object format.
● pm.cookies.jar() : To get or set cookies with specific domain name and associate with request.
Example:
const jar = pm.cookies.jar()
jar.set("https://reqres.in", "session-id", "abc123", (error, cookie) => {
if (error) {
console.error(`An error occurred: ${error}`);
} else {
console.log(`Cookie saved: ${cookie}`);
}
});
(Note: To work with cookies jar, need to add domain to whitelisted domains under Cookies)
Thank you
For more details,
Mail us @ training@itlearn360.com
Call us @ +1-800-543-5571
https://www.itlearn360.com

More Related Content

Similar to Postman API testing with pre & post scripting

Qtp Presentation
Qtp PresentationQtp Presentation
Qtp Presentation
techgajanan
 
Assurer - a pluggable server testing/monitoring framework
Assurer - a pluggable server testing/monitoring frameworkAssurer - a pluggable server testing/monitoring framework
Assurer - a pluggable server testing/monitoring framework
Gosuke Miyashita
 
Qtp framework implementation_guide_v1
Qtp framework implementation_guide_v1Qtp framework implementation_guide_v1
Qtp framework implementation_guide_v1
Saurabh Singh
 

Similar to Postman API testing with pre & post scripting (20)

GraphConnect 2014 SF: From Zero to Graph in 120: Scale
GraphConnect 2014 SF: From Zero to Graph in 120: ScaleGraphConnect 2014 SF: From Zero to Graph in 120: Scale
GraphConnect 2014 SF: From Zero to Graph in 120: Scale
 
Unit Testing from Setup to Deployment
Unit Testing from Setup to DeploymentUnit Testing from Setup to Deployment
Unit Testing from Setup to Deployment
 
MT_01_unittest_python.pdf
MT_01_unittest_python.pdfMT_01_unittest_python.pdf
MT_01_unittest_python.pdf
 
More on Fitnesse and Continuous Integration (Silicon Valley code camp 2012)
More on Fitnesse and Continuous Integration (Silicon Valley code camp 2012)More on Fitnesse and Continuous Integration (Silicon Valley code camp 2012)
More on Fitnesse and Continuous Integration (Silicon Valley code camp 2012)
 
Qtp Presentation
Qtp PresentationQtp Presentation
Qtp Presentation
 
Local data storage for mobile apps
Local data storage for mobile appsLocal data storage for mobile apps
Local data storage for mobile apps
 
Tutorial on developing a Solr search component plugin
Tutorial on developing a Solr search component pluginTutorial on developing a Solr search component plugin
Tutorial on developing a Solr search component plugin
 
Assurer - a pluggable server testing/monitoring framework
Assurer - a pluggable server testing/monitoring frameworkAssurer - a pluggable server testing/monitoring framework
Assurer - a pluggable server testing/monitoring framework
 
Overview of RESTful web services
Overview of RESTful web servicesOverview of RESTful web services
Overview of RESTful web services
 
Automating Research Data with Globus Flows and Compute
Automating Research Data with Globus Flows and ComputeAutomating Research Data with Globus Flows and Compute
Automating Research Data with Globus Flows and Compute
 
What’s new in WSO2 Enterprise Integrator 6.6
What’s new in WSO2 Enterprise Integrator 6.6What’s new in WSO2 Enterprise Integrator 6.6
What’s new in WSO2 Enterprise Integrator 6.6
 
MidSem
MidSemMidSem
MidSem
 
Slice for Distributed Persistence (JavaOne 2010)
Slice for Distributed Persistence (JavaOne 2010)Slice for Distributed Persistence (JavaOne 2010)
Slice for Distributed Persistence (JavaOne 2010)
 
Enhanced Web Service Testing: A Better Mock Structure
Enhanced Web Service Testing: A Better Mock StructureEnhanced Web Service Testing: A Better Mock Structure
Enhanced Web Service Testing: A Better Mock Structure
 
WSO2 Product Release Webinar: WSO2 Complex Event Processor 4.0
WSO2 Product Release Webinar: WSO2 Complex Event Processor 4.0WSO2 Product Release Webinar: WSO2 Complex Event Processor 4.0
WSO2 Product Release Webinar: WSO2 Complex Event Processor 4.0
 
Struts2 - 101
Struts2 - 101Struts2 - 101
Struts2 - 101
 
Testing the frontend
Testing the frontendTesting the frontend
Testing the frontend
 
Qtp framework implementation_guide_v1
Qtp framework implementation_guide_v1Qtp framework implementation_guide_v1
Qtp framework implementation_guide_v1
 
ssssssssss
ssssssssssssssssssss
ssssssssss
 
EContent_11_2023_04_09_11_30_38_Unit_3_Objects_and_Classespptx__2023_03_20_12...
EContent_11_2023_04_09_11_30_38_Unit_3_Objects_and_Classespptx__2023_03_20_12...EContent_11_2023_04_09_11_30_38_Unit_3_Objects_and_Classespptx__2023_03_20_12...
EContent_11_2023_04_09_11_30_38_Unit_3_Objects_and_Classespptx__2023_03_20_12...
 

Recently uploaded

Recently uploaded (20)

Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 

Postman API testing with pre & post scripting

  • 1. Postman API Scripts Postman response assertions with JS scripts
  • 2. Points to discuss ● Scripting in Postman ● Execution order of scripts ● Hierarchy of scripts ● Script globals, Scope ● Cred operations for local scope ● Cred operations for global scope ● Cred operations for collections scope ● Cred operations for env scope ● Dynamic variables & debugging ● Scripting with request and response data
  • 3. Scripting in Postman Scripting in Postman will help you to automate the process to test the output of given REST API, HTTP API or SOAP API. ● Postman supports a powerful runtime platform “Node.js” that allows you to add dynamic behavior to requests and collections. ● This allows you to write test suites, build requests that can contain dynamic parameters, pass data between requests, and a lot more. ● We can add scripts to pre-request scripts tab and tests tab under request.
  • 4. Execution order of scripts As discussed, we can add script to automate testing in Pre-request script & tests tabs of request window. Pre-request script associated with any request in postman ● Always execute before request is sent. ● Perform the operation and add variable or env variable to request if any. Test script associated with any request in postman ● Always execute after request is sent.
  • 5. Hierarchy of scripts Pre-request script & tests script can be add into 3 levels. Collections level ● A pre-request script associated with a collection will run prior to every request in the collection. ● A test script associated with a collection will run after every request in the collection. Folder level ● A pre-request script associated with a folder will run prior to every request in the folder. ● A test script associated with a folder will run after every request in the folder. Request level ● A pre-request script associated with a request will run before every request is sent. ● A test script associated with a request will run after to every request is sent.
  • 6. Script globals, Scope pm object It is postman object which provides to functionality for testing your request and response data. The pm object provides methods for accessing global, collection, and environment variables specifically, and pm.variables methods for accessing variables at different scopes as well as setting local variables. pm.variables: dictionary or associative variable of pm object for local scope It helps to store variables with its value within request scope & access in request scope. pm.globals: dictionary or associative variable of pm object for global scope It helps to store variables with its value. This scope will use when it needs to pass variables to other requests.
  • 7. Script globals, Scope pm.collectionVariables: dictionary or associative variable of pm object for collections scope It is good alternative to global or environment variables and store credentials & pass to requests within postman collection. pm.environment: dictionary or associative variable of pm object for environment specific Environment variables are tied to the selected environment(test, dev or production). It is good alternative to global variables as they have a narrower scope. It can be used to storing environment specific information, URLs, authentication credentials & passing data to other requests. pm.iterationData: dictionary or associative variable of pm object for iteration only It can be used during execution of iteration or multiple data-sets are needed.
  • 8. Cred operation for local scope 1. Set or create variable to local scope or request scope itself: in this case, we will set scope named variable with its value… pm.variables.set(“scope”,”request”) To store variable, it needs to provide key & value pair. 1. Get or read value of specific variable: pm.variables.get(“scope”) 1. Check specific variable exists in local scope pm.variables.has(“scope”) Return value can be true or false 1. Delete specific variable from local scope pm.variables.unset(“scope”)
  • 9. Cred operation for Global scope 1. Set or create variable to global scope: in this case, we will set scope named variable with its value… pm.globals.set(“scope”,”global”) To store variable, it needs to provide key & value pair. 1. Get or read value of specific variable: pm.globals.get(“scope”) 1. Check specific variable exists in global scope pm.globals.has(“scope”) Return value can be true or false 1. Delete specific variable from global scope pm.globals.unset(“scope”) 1. Delete all variable from global scope pm.globals.clear()
  • 10. Cred operation for Collections scope 1. Set or create variable to collection(can be access in all requests of specific collections) scope: in this case, we will set scope named variable with its value… pm.collectionVariables.set(“scope”,”collection”) To store variable, it needs to provide key & value pair. 1. Get or read value of specific variable: pm.collectionVariables.get(“scope”) 1. Check specific variable exists in collection scope pm.collectionVariables.has(“scope”) Return value can be true or false 1. Delete specific variable from collection scope pm.collectionVariables.unset(“scope”)
  • 11. Cred operation for environment scope 1. Set or create variable to environment(can be access in all requests of specific environment) scope: in this case, we will set scope named variable with its value… pm.environment.set(“scope”,”env”) To store variable, it needs to provide key & value pair. 1. Get or read value of specific variable: pm.environment.get(“scope”) 1. Check specific variable exists in environment scope pm.environment.has(“scope”) Return value can be true or false 1. Delete specific variable from environment scope pm.environment.unset(“scope”) 1. Delete all variable from global scope pm.environment.clear()
  • 12. Dynamic variables & Debugging Postman provides the faker library to generate dynamic dummy data. We can generate random names, addresses, email addresses, and much more. You can use these pre-defined variables multiple times to return different values per request. Dynamic variables’ values are generated at the time of execution and their names start with a $ symbol e.g. $guid, $timestamp etc. To use dynamic variables in pre-request or test scripts, you need to use pm.variables.replaceIn(), e.g. pm.variables.replaceIn('{{$randomFirstName}}'). Common variables are: $guid: A uuid-v4 style guid $timestamp: The current UNIX timestamp in seconds $isoTimestamp: The current ISO timestamp at zero UTC $randomUUID: A random 36-character UUID More reference: https://learning.postman.com/docs/writing-scripts/script-references/variables-list/
  • 13. Dynamic variables & Debugging Continued... To debugging in pre-request script or tests tab just use console.log. Let's take some examples of some code snippets 1. To check variable in exists in local scope console.log(pm.variables.has(“scope”)) //output will be true 1. To get the value of scope variable in local scope console.log(pm.variables.get(“scope”)) // output will be request Let’s define one variable with local scope and debugging value: pm.variables.set(“scope”,”request”); console.log(pm.variables.get(“scope”)) // output will be request Let’s update the value of defined variable of local scope pm.variables.set(“scope”,”updated request”); console.log(pm.variables.get(“scope”)) // output will be updated request Note: to check console window go to view menu from top→ show console
  • 14. Scripting with request and response data To send the request or get the response data or process the response data, postman scripts provides a variety of methods like pm.request : it provides the pre-defined variables & methods to send or perform ops on postman request Properties & methods of pm.request ● pm.request.url : request url ● pm.request.headers: list of request headers which stores various data in key, value regarding the requests. ● pm.request.method : HTTP request like PUT, GET, DELETE, POST, HEAD etc. pm.response: it provides the pre-defined variables & method to work or get the data of returned data of sent request. Properties & methods of pm.response ● pm.response.code : HTTP response code which can be in range of 100-599
  • 15. Scripting with request and response data Variables of pm.response ● pm.response.status : HTTP response text string ● pm.response.headers: list of headers returned by sent request ● pm.response.responseTime : The time the response took to receive in milliseconds ● pm.response.responseSize : The size of the response received ● pm.response.text() : Get the text of response ● pm.response.json() : Get the text of response in json format pm.info : it provides the information related to request including event name, ID, iteration count etc. Properties & methods of pm.info ● pm.request.eventName: the event which can be pre-request or tests depending on where the script is executing within the request. ● pm.info.iteration : The total number of iterations that are scheduled to run ● pm.info.requestName: The saved name of the request running ● pm.info.requestId: A unique id of request in GUID format
  • 16. Scripting with request and response data pm.cookies : A objects provide the access the list of cookies associated with request. Properties & methods of pm.cookies ● pm.cookies.has(cookiename): to check whether the cookie exists in request or not. Just provide the name cookie as parameter in method. ● pm.cookies.get(cookiename) : To get the value of specified cookie as parameter ● pm.cookies.toObject(): To get a copy of cookies with values in object format. ● pm.cookies.jar() : To get or set cookies with specific domain name and associate with request. Example: const jar = pm.cookies.jar() jar.set("https://reqres.in", "session-id", "abc123", (error, cookie) => { if (error) { console.error(`An error occurred: ${error}`); } else { console.log(`Cookie saved: ${cookie}`); } }); (Note: To work with cookies jar, need to add domain to whitelisted domains under Cookies)
  • 17. Thank you For more details, Mail us @ training@itlearn360.com Call us @ +1-800-543-5571 https://www.itlearn360.com