在JMeter中,如何从REST POST请求(而不是响应)中捕获值?

在JMeter中,如何从REST POST请求(而不是响应)中捕获值?,jmeter,jmeter-4.0,Jmeter,Jmeter 4.0,REST POST请求的一部分如下所示,其中我传递了VIN和经销商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:ty

REST POST请求的一部分如下所示,其中我传递了VIN和经销商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
${vin}
经销商ID
${dealer_id}
我需要从${vin}和${dealer_id}中提取值,这样我就可以在CSV报告中包含这些值以及从响应中捕获的其他值。我知道如何从响应中捕获值,但不知道如何从请求中的变量中捕获值。有人能帮忙吗?谢谢

只需使用属性

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

  • 下次你喜欢的时候:

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


  • 如果您想将这些值存储到一个单独的文件中,您可以使用plugin,即plugin

    vin
    是JMeter变量,因此它已经被捕获了,不是吗?
    sample_variables=vin,dealer_id
    
    jmeter -n -t test.jmx -l result.jtl