Data-Driven Testing in POSTMAN

Data-driven Testing is nothing but getting testing data from a different file. Data can be stored in different data storage applications such as Excel, notepad, Wordpad, etc. Data are not generally stored in a single format but in different formats.

Data-driven testing can be done in two different ways. One is the way to use the data from a file. And the other way is to use the data from a different request-response.

The data stored in the file can be used for different applications such as CSV, JSON, HTML, etc. To get the data from a different file, first, we have to create variables and then the data stored in the file can be referred to.

CSV file

To show the application of data-driven testing, we shall use a CSV file. A CSV file is a file that contains all the values separated by a comma(,). And so the CSV is the acronym for comma-separated values. The data stored in the CSV file is easily understandable and can be easily retrieved.

Creating Global Variables

First, create global variables that can be substituted in the request URL and in the body. To create global variables first go to the manage environment icon on the top-right corner on the homepage of the POSTMAN software. And then, go to globals and input the variables.

Go to manage Environment in POSTMAN :


Then, go to globals :

Now, enter the variable names and enter the corresponding values. I have named my variables as- endpoint, email, and password.


Now, go back to the request page and then replace the endpoint values with the variable name in the URL bar. And also replace the values in the body with the appropriate variable name.

Now, save and send the request and see whether the request is generating the same response.

Now, you have seen that variables can be used in the request URL as well as in the body.

Now, we shall see how to get the same values from a CSV file. That is we shall create a CSV(Comma Separated Value) file and will have some values like: end-point, email, and password.

Now, just go to any folder or location of your computer and create a file called data01.csv

Now, save the file in any location you want and reopen it in any text editor, and just put a (,) after all the values inside. This is done to indicate a CSV(comma-separated value) file. In case, not separated by a comma, there can be a format-related error at the time of running the collection.

I have used notepad++ software to open the file and edit it.

Now, to the collection runner and select the Data File Type as text/CSV file there. Also, upload the file there using the Select File button.

Now, run the collection by clicking the Run Collection button on the same page.

Now, the response, along with all the details can also be exported into any folder you want. Just click on the export button on the top-right corner of the collection runner page and export the file.

Now, the location, you selected at the time of saving, check on that location for your exported file.

Similarly, the way to import data from a json file is also the same. Just write the script in a text file, save it as a json file, and address the file in the collection runner.

This is how a json file looks like. There are three values- endpoint, email, and password.

    "endpoint": "api/users?page=2",
    "email": "[email protected]",
    "password": "pistol"

Now, select your file in the Collection runner window:

The report file can be exported in a similar way as we did.

Postman Interview Questions

Data-Driven Testing using Data Cascading

Data cascading is nothing, but using data from one response and using it into another variable. Data cascading can be done in different ways such as- Single Level cascading, Multi-level cascading, and multiple cascading.

It is possible to get the data from one response of an API and fetch the same data into a different API. Now, let us see how you can do it.

First of all, you have to create two different requests. I shall use the same collection, and inside it, I shall create two API requests. One is the GET type and the other is a POST type. The way to create the API request is the same. Visit the same link- And select the requests.

For the first API request, select the GET: List User. Then copy the URL and also the request endpoint and then create the request. (This is your first request).

Now, paste it into the URL bar of the first request and create your first request and name it. I have named it as: list-user.

Now, create the second request. Visit the link: And then select the PUT: Update.

Copy the URL and the request end-point and paste it into the URL bar of your second request. I have named it as: update-user.

Now, you have created both the requests.

Now, the next step is to parameterize the value in the body section of the request. Go to the second request (update user) and navigate to the body section and then select the raw. Then select a field and replace it with a variable.

So, my original content of the body was:

    "name": "morpheus",
    "job": "zion resident"

And now I have to change the morpheus into username01.

    "name": "{{username01}}",
    "job": "zion resident"

Now, the username01 is a variable and has to be updated as a global variable or environment variable. I shall select the environment variable.

To set an environment variable, go to the Manage environment (gear icon) in the top-right corner of the POSTMAN interface or create a new environment by clicking on the New button.

Now, click on the send button and see the output. As you can see below, the name which morpheus earlier is now changed to rahul

Fetching data from API Response

Now, to fetch the data from the API response, navigate to the first API response. And go to the Tests option. And edit the below code there:

bodyData = JSON.parse(responseBody)
value =[3].first_name

The data[3].first_name is the path of the first name. So, to get the path, visit: and then paste the response test into the editor of the website and then navigate into the right-side of the same page to get the path:

Now, paste it into the json Path finder.

Now, click into data, of the attributes and the corresponding path will be available above in the path bar. Then copy the path.

Now, also you can set variables as Global Variables. As there are different snippets available into the POSTMAN interface itself, you can use it simply and write the code for Global Variable.

Now edit the below code into the Text section of your second API request:

bodyData = JSON.parse(responseBody)
value =[3].first_name
pm.environment.set("username01", value);

After that, save it, and click on the send button. And now check into your current environment, whether the variable has automatically taken the value:

So, in the above image, it is visible that the variable username01 has been initialized with the value Byron. And so the current value is also the same for the variable.

Create both the request in the same environment, and try to execute the same under the same environment.
0 results
Comment / Suggestion Section
Point our Mistakes and Post Your Suggestions