【问题标题】:In JMeter, how to capture values from REST POST Request (not the Response)?在 JMeter 中,如何从 REST POST 请求(而不是响应)中捕获值?
【发布时间】:2019-10-31 16:03:32
【问题描述】:

REST POST 请求的一部分如下所示,其中我为 VIN 和 DEALER_ID 传递了不同的值:

        <ns3:PARAM>
              <ns3:ITEM>VIN</ns3:ITEM>
              <ns3:VALUE xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xs:string">${vin}</ns3:VALUE>
        </ns3:PARAM>
        <ns3:PARAM>
              <ns3:ITEM>DEALER_ID</ns3:ITEM>
              <ns3:VALUE xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xs:string">${dealer_id}</ns3:VALUE>
        </ns3:PARAM>

我需要从 ${vin} 和 ${dealer_id} 中提取值,因此我可以在 CSV 报告中使用我从响应中捕获的其他值。我知道如何从响应中捕获值,但不知道如何从请求中的变量中捕获。有人可以帮忙吗?谢谢。

【问题讨论】:

  • vin 是 JMeter 变量,所以它已经被捕获了,不是吗?

标签: jmeter jmeter-4.0


【解决方案1】:

只需使用Sample Variables 属性

  1. 将下一行添加到 user.properties 文件:

    sample_variables=vin,dealer_id
    
  2. 下次你run JMeter script in command-line non-GUI mode点赞:

    jmeter -n -t test.jmx -l result.jtl
    

    result.jtl 文件将有 2 个额外的列:vindealer_id 保存每个请求的相应 JMeter 变量的值

如果您想将值存储到单独的文件中,您可以使用 Flexible File Writer 插件

【讨论】:

    猜你喜欢
    • 2013-05-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多