How to save response in a variable in jmeter

后端 未结 4 1287
無奈伤痛
無奈伤痛 2021-02-13 16:56

I am performing load testing on my server using jmeter. In one of my post requests, I receive a unique id in the response. I need to send this id as a parameter in the following

4条回答
  •  情深已故
    2021-02-13 17:13

    If you need to store the whole response into a variable - take the following steps:

    1. Add Beanshell PostProcessor as a child of the request which returns response you're looking for
    2. Put the following line into the PostProcessor's "Script" area:

      vars.put("response", new String(data));
      
    3. Refer extracted value as ${response} where required

      See How to Use BeanShell: JMeter's Favorite Built-in Component guide to lean more about Beanshell scripting in JMeter


    Alternatively you can do the same with the Regular Expression Extractor, in that case relevant configuration will be:

    • Reference Name: response
    • Regular Expression: (?s)(^.*)
    • Template: $1$

    If you need a part of response, not the whole response you can amend Regular Expression according to your needs as per Regular Expressions chapter of JMeter's User Manual

提交回复
热议问题