javascript - Can I provide a json path in CSV file in postman
问题描述
I was trying to execute a postman collection that has many iteration. Data was provided in CSV format.
In each iteration i want to compare different nodes with expected messages provided in the datafile, for example,
sample collection:
{
"message": [{
"code": XYX,
"abc": "how are you",
"def": "where are you from"
"ghi": "your name",
"jkl": "place"
}]
}
in 1st iteration - my test is as below
pm.response.json().message[0].code.to eql(data.ExpectedErrorMessage);
2nd iteration,
pm.response.json().message[0].abc.to eql(data.ExpectedErrorMessage);
and so on.
I have 100 + nodes and many arrays in the list. so its not feasible to write test for each node separately. Instead, i want to write a generic test and keep the response path in CSV file.
I tried by providing the path in below way in my data file.But i am unable to perform my test. I am getting the assertion error
[
{
"TC_ID": "TC_001",
"TC_NAME": "abc",
"path": "pm.response.json().message[0].code",
"ExpectedErrorMessage": "XYZ"
},
{
"TC_ID": "TC_002",
"TC_NAME": "def",
"path": "pm.response.json().message[0].abc",
"ExpectedErrorMessage": "how are you"
}
]
解决方案
推荐阅读
- java - 我怎样才能将凌空响应存储在请求中的变量中?
- python - 替换在另一个数据帧中找到的一个数据帧上的所有字符串实例
- javascript - 每分钟/小时刷新一次包含 importxml 和 importhtml 的谷歌表格的脚本
- android - 如何使用 Billing library 3.0 创建订阅和购买?
- python - 这个函数的大 O 时间是多少(来自 LeetCode 的加一个问题)
- visual-studio-code - 命令在 Ubuntu 终端中运行,但不在 vscode 终端中运行
- c# - DateTime.Parse 正在从 DataRow 中减少毫秒?
- ssl - 物联网设备的自签名证书或 CA 证书
- java - R 通过 JDBC 连接到 SQL Server - 驱动程序版本错误
- c# - System.DirectoryServices.Protocol LDAP 查询导致 LDAP 服务器返回未知错误