试图测量邮递员中特定参数的长度
我是新手,没有足够的经验在Postman中写测试脚本。目前,我正在尝试提取以下响应的特定变量(组织名称)的长度
{
"data": [
{
"name": "Test1 AB",
"organizationnumber": "1234566293"
},
{
"name": "Test AB",
"organizationnumber": "1234564007"
}
]
}
,并且我正在尝试在Postman中遵循测试脚本以获取长度
pm.test("organizationnumber length is 10", () => {
const responseJson = pm.response.json();
pm.expect(responseJson.organizationnumber).to.have.lengthOf(10);
,并且我收到了测试案例的以下错误消息:
组织名称长度为10 | essertionError:目标不能无效或未定义。
I am newbee and don't have enough experience writing test script in postman. At the moment I am trying to extract length of a specific variable(organizationnumber) for the following response
{
"data": [
{
"name": "Test1 AB",
"organizationnumber": "1234566293"
},
{
"name": "Test AB",
"organizationnumber": "1234564007"
}
]
}
And I am trying following test script in postman to get length
pm.test("organizationnumber length is 10", () => {
const responseJson = pm.response.json();
pm.expect(responseJson.organizationnumber).to.have.lengthOf(10);
And I am getting following error message for test case:
organizationnumber length is 10 | AssertionError: Target cannot be null or undefined.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要在响应中迭代数组:
You need to iterate over the array in the response: