【问题标题】:How can I find response cookie names in Postman tests?如何在 Postman 测试中找到响应 cookie 名称?
【发布时间】:2019-08-06 22:29:04
【问题描述】:

有没有办法在 Postman 测试中检索响应 cookie 名称?我可以使用postman.getResponseCookie("<COOKIENAME>").value 获取值。但是,根据不同的场景,cookiename 会发生变化。

【问题讨论】:

标签: testing cookies postman


【解决方案1】:

知道了!我评估了responseCookies 以确定cookie 名称。

【讨论】:

  • 你能详细说明一下吗?
  • 我知道,并且已经在问题文本中说明了。您如何获得 cookie 名称?
  • console.log(responseCookies);
【解决方案2】:

您可以像这样在测试中检查特定的 cookie:

pm.test("Response contains a JSESSIONID cookie", function() {
    pm.expect(pm.cookies.has('JSESSIONID')).to.be.true;
});

这适用于我在没有打开 Postman 拦截器的 Postman v7.3.6 中。

【讨论】:

    猜你喜欢
    • 2019-10-04
    • 1970-01-01
    • 1970-01-01
    • 2021-07-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多