我想在我的纽曼报告中列出我的邮差收藏的请求名称。因此,我在脚本中添加了以下代码,
pm.test(`${request.name}: Status Assertion`, function () { pm.response.to.have.status(401); });
我正确地获得了请求名称。然而,我在控制台中收到以下警告,
当我使用pm.request时,
console.log('Request name: ',pm.request.name)
我得到的值是未定义的,
如何摆脱警告并获得请求的名称?
提前感谢
这应该使用 pm.info.requestName 取而代之的是这里。
pm.info.requestName
https://learning.postman.com/docs/tests-and-scripts/write-scripts/postman-sandbox-api-reference/#scripting-with-request-info
你也可以利用新的 pm.execution.location.current 函数。
pm.execution.location.current
https://learning.postman.com/docs/tests-and-scripts/write-scripts/postman-sandbox-api-reference/#get-the-path-and-name-of-a-request