0
0
Postmantesting~5 mins

Global variables in Postman - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a global variable in Postman?
A global variable in Postman is a value stored that can be accessed by any request or script within the Postman workspace. It helps share data across multiple requests.
Click to reveal answer
beginner
How do you set a global variable in a Postman test script?
You use pm.globals.set('variableName', 'value') to create or update a global variable in Postman.
Click to reveal answer
beginner
How can you retrieve a global variable's value in Postman scripts?
Use pm.globals.get('variableName') to get the value of a global variable in Postman scripts.
Click to reveal answer
intermediate
What is the difference between global variables and environment variables in Postman?
Global variables are accessible across all environments and requests, while environment variables are specific to a selected environment and help manage different setups like dev, test, or prod.
Click to reveal answer
intermediate
Why should you be careful when using global variables in Postman?
Because global variables are shared across all requests and environments, accidental changes can affect many tests. It's best to use them only when needed and clean up after tests.
Click to reveal answer
Which Postman method sets a global variable?
Apm.globals.set('name', 'value')
Bpm.environment.set('name', 'value')
Cpm.variables.set('name', 'value')
Dpm.request.set('name', 'value')
How do you access a global variable's value in Postman?
Apm.collection.get('variableName')
Bpm.environment.get('variableName')
Cpm.request.get('variableName')
Dpm.globals.get('variableName')
What is a key difference between global and environment variables in Postman?
AGlobal variables cannot be changed during runtime.
BEnvironment variables are shared globally; global variables are environment-specific.
CGlobal variables are shared across all environments; environment variables are environment-specific.
DEnvironment variables are only for authentication.
Why might overusing global variables be risky in Postman?
AThey slow down the Postman app.
BThey can cause unexpected test failures if changed unintentionally.
CThey are not saved between sessions.
DThey cannot store string values.
Which of these is NOT a valid way to clear a global variable in Postman?
Apm.globals.remove('variableName')
Bpm.globals.unset('variableName')
Cpm.globals.set('variableName', null)
Dpm.globals.clear()
Explain what global variables are in Postman and how they differ from environment variables.
Think about scope and sharing of variables.
You got /4 concepts.
    Describe how to set, get, and clear a global variable in Postman scripts.
    Focus on the Postman scripting API methods.
    You got /4 concepts.