Can we read data from excel in postman for js test

2019-06-07 19:54发布

问题:

Can we read data from excel in postman for js tests? OR can we write a js script which read data from excel/csv/notepad.

I have wrote some js script which automate my API tests. I am using Newman to execute them from command prompt.

I am writing automated test in postman. I want to import data from excel for my tests. Is it possible? There is any plug-in or anything present which can help me to achieve same

I have a thought that using js I try to write a code which directly read/interacts file like excel/csv/notepad. Is it possible?

Any help would be appreciated

回答1:

You can if you export your excel to csv and the format is similar to this file.

You can also do this with newman using -d <source>, --iteration-data <source>.

Specify a data source file (CSV) to be used for iteration as a path to a file or as a URL. Working with data files.

If you want to use Postman app, you can use the Collection Runner -

The Collection Runner let’s you import a CSV or a JSON file and then use the values from the data file inside HTTP requests and scripts. We call these variables data variables. To use them inside the Postman UI, you have to follow the same syntax as environment or global variables. Having the same syntax helps you test individual requests inside Postman using dummy environment values. When you move to the Collection Runner you don't have to change anything.

More on the blog here.