Hello folks,

We have already seen creating, managing and using environment variables in Postman.

We can select only single environment at a time in Postman and can use variables of that selected environment. We may have some variables which are common to each environment. It is not good practice to keep a separate copy of each common variable in each environment. It will not be a good architectural design.

Postman has something called Global variables which are available globally in fact at any scope. You can use global variables with or without selecting any environment. You can use global variables wherever you can use variables of an environment. Remember global variable does not belong to any specific environment.

Enough of theory, let’s create global variables:-

  1. Click on “Manage Environment” icon at right top corner of Postman tool.

2. You will see below screen:

3. Click on “Global” button. Pass the desired variable’s name and it’s an initial value. Process is same as creating an environment variable. Only difference is that here you do not provide Environment name.

4. Click on Save button. You can see all variables ( Environment and Global) by clicking on “Environment quick look” icon.

5. You can quickly edit variables by clicking on provided edit button as well. Save button will be enabled as soon as there is any unsaved changes.

Accessing any global variable:-

To use any global variable, it is not mandatory to choose any environment in drop down. We just need to use variable name as placeholder {{variableName}}. This placeholder will be replaced with its current value. For example: – {{URL}} will be replaced by “https://gorest.co.in/ ” from the declared global variable named “URL”.

You can see value by mouse hovering on {{URL}}.

Remember variable name is case sensitive. URL and url are two different variables.

Important point to remember:-

Environment variable will take precedent always on global variable if found in both scope. If a selected environment has a variable which is also available in global scope, variable from environment will take precedence.

More about API Testing in upcoming posts. Stay tuned.

If you have any doubt, feel free to comment below.
If you like my posts, please like, comment, share and subscribe.
#ThanksForReading
#HappyApiTesting

Author: Amod Mahajan

My name is Amod Mahajan and I am an IT employee with 6+ years of experience in Software testing and staying in Bengaluru. My area of interest is Automation testing. I started from basics and went through so many selenium tutorials. Thanks to Mukesh Otwani as his tutorials are easy and cover basics to advance. I have habit of exploring concepts by deep diving. I used to make notes. I thought of sharing my knowledge through posts and now I am here. #KeepLearning #ShareLearning

Leave a Reply