2

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

Shubham Jain
  • 16,610
  • 15
  • 78
  • 125

1 Answers1

3

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.

Pratik Mandrekar
  • 9,362
  • 4
  • 45
  • 65
  • 1
    And if you are on version 5+ of the Postman native app you can automatically schedule your collection run using monitors - https://www.getpostman.com/docs/postman/monitors/setting_up_monitor – Pratik Mandrekar Jun 15 '17 at 13:35
  • Yes I have done same thing already by using postman just now. But challenge will be with newman .. A terminal node base plug-in which will execute it from command line. I am upvoted for your efforts. Thanks – Shubham Jain Jun 15 '17 at 14:19
  • As I said you can use monitors that let you schedule test runs from within Postman and make use of this functionality. – Pratik Mandrekar Jun 15 '17 at 14:43
  • I just check the monitor function and it is awesome.. Thanks for the great sharing and good thing is it is free ... Just I am stuck with the data passing using csv now... If it will fix my task is almost done.. – Shubham Jain Jun 16 '17 at 07:06
  • I am facing problem where my data files is only can be passed by collection runner so monitor failing them ... do you any good approach – Shubham Jain Jun 16 '17 at 07:07
  • Thanks Pratik -d works fine with newman :) .. Accepting answer ;) – Shubham Jain Jun 16 '17 at 07:21
  • Just you can tell me that how I can use it with monitor then it will be a great help ... – Shubham Jain Jun 16 '17 at 07:21
  • -> I have open an another ticket. May you can help me this . https://stackoverflow.com/questions/44588880/how-to-pass-csv-data-in-postman-collection-so-monitor-can-pick-it – Shubham Jain Jun 16 '17 at 12:14