Recall & Review
beginner
What is the purpose of setting variables in Postman scripts?
Setting variables in Postman scripts helps store and reuse data like tokens, IDs, or responses across requests, making tests dynamic and efficient.
Click to reveal answer
beginner
How do you set an environment variable in a Postman test script?
Use
pm.environment.set('variableName', 'value'); to set an environment variable.Click to reveal answer
intermediate
What is the difference between
pm.environment.set() and pm.collectionVariables.set()?pm.environment.set() sets a variable for the current environment only, while pm.collectionVariables.set() sets a variable that is available throughout the collection regardless of environment.Click to reveal answer
beginner
How can you access a variable value in a Postman script?
Use
pm.variables.get('variableName'); to get the value of a variable from any scope (environment, collection, globals).Click to reveal answer
intermediate
Why is it useful to set variables dynamically during test execution?
Setting variables dynamically allows tests to adapt to changing data, like capturing tokens or IDs from responses and using them in later requests, making tests realistic and maintainable.
Click to reveal answer
Which method sets a global variable in Postman scripts?
✗ Incorrect
Global variables are set using pm.globals.set(). Environment and collection variables use their respective methods.
How do you retrieve a variable value in a Postman script?
✗ Incorrect
pm.variables.get() retrieves the value from any scope, making it the most flexible method.
What is the scope of a variable set with pm.environment.set()?
✗ Incorrect
pm.environment.set() sets variables only for the active environment.
Why would you set a variable in a test script after receiving a response?
✗ Incorrect
Storing data like tokens or IDs from responses allows chaining requests dynamically.
Which Postman object is used to set variables in scripts?
✗ Incorrect
The pm object provides methods to set and get variables in scripts.
Explain how to set and use an environment variable in a Postman test script.
Think about storing data from a response to use in the next request.
You got /4 concepts.
Describe the difference between environment, global, and collection variables in Postman.
Consider where the variable is available and how it affects multiple requests.
You got /4 concepts.