简体   繁体   English

我们可以从 postman 中的 excel 中读取数据以进行 js 测试吗?

[英]Can we read data from excel in postman for js tests?

Can we read data from excel in postman for js tests?我们可以从 postman 中的 excel 中读取数据以进行 js 测试吗? OR can we write a js script which read data from excel/csv/notepad.或者我们可以编写一个从 excel/csv/notepad 读取数据的 js 脚本。

I have wrote some js script which automate my API tests.我写了一些 js 脚本来自动化我的 API 测试。 I am using Newman to execute them from command prompt.我正在使用 Newman 从命令提示符执行它们。

I am writing automated test in postman.我正在邮递员中编写自动化测试。 I want to import data from excel for my tests.我想从 excel 导入数据用于我的测试。 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.我有一个想法,使用 js 我尝试编写一个直接读取/交互文件的代码,如 excel/csv/notepad。 Is it possible?有可能吗?

Any help would be appreciated任何帮助将不胜感激

You can if you export your excel to csv and the format is similar tothis file .如果您将 excel 导出为 csv 并且格式类似于此文件,则可以

You can also do this with newman using -d <source>, --iteration-data <source> .您也可以使用-d <source>, --iteration-data <source>newman执行此操作。

Specify a data source file (CSV) to be used for iteration as a path to a file or as a URL.将要用于迭代的数据源文件 (CSV) 指定为文件路径或 URL。 Working with data files . 处理数据文件

If you want to use Postman app, you can use the Collection Runner -如果您想使用 Postman 应用程序,您可以使用 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. Collection Runner 可让您导入 CSV 或 JSON 文件,然后在 HTTP 请求和脚本中使用数据文件中的值。 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.要在 Postman UI 中使用它们,您必须遵循与环境或全局变量相同的语法。 Having the same syntax helps you test individual requests inside Postman using dummy environment values.使用相同的语法可以帮助您使用虚拟环境值测试 Postman 中的各个请求。 When you move to the Collection Runner you don't have to change anything.当您移动到 ​​Collection Runner 时,您无需进行任何更改。

More on the blog here .更多关于这里的博客。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM