How to save response in a variable in jmeter

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

    I know this question is old but I agree with @UBIK you should probably use a JSON extractor. I am working with a load test that is sending over 100 requests per second and I need to reuse the value in a specific JSON key, so I'm using a JSON extractor and saving the values in a .csv file to be used by the next request.

    1. extract the JSON


    2. This is the Groovy script to write it to a .csv file

     def myRandomIds = new File("randomIds.csv")
        myRandomIds << vars.get("id") + ","
        myRandomIds << System.getProperty("line.separator")
        log.info(vars.get("id") + " saved to randomIds.csv...")
    

    1. This is the CSV data config I have set up in my other request that is reading from the csv file. (In my case these .jmx files are automated and parametized using jenkins)


    2. CSV data set config


提交回复
热议问题