How to save response in a variable in jmeter

后端 未结 4 1292
無奈伤痛
無奈伤痛 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:32

    If you really need to store the whole response into a variable, do the following:

    1. Add JSR223 PostProcessor as a child of the request which returns response you're looking for

    1. Put the following line into the "Script" area:

    vars.put("response", prev.getResponseDataAsString());

    1. Use then this response as ${response} where you need it

    But you rarely need to use the whole response and you should avoid it for big , in this case it is much better to use the Extractor that suits your response format:

    • JSON Extractor for JSON
    • CSS/JQuery Extractor for HTML extraction
    • XPath Extractor for XML
    • Regular Expression Extractor for all of them or any textual format

提交回复
热议问题