Save body request in JMeter

后端 未结 3 1023
慢半拍i
慢半拍i 2021-01-28 18:58

I am using CSV file which contains variables for my XML requests. I know how to see the request sent, but I would like to save each request in

3条回答
  •  无人及你
    2021-01-28 19:43

    The easiest way seems to be using Flexible File Writer, you can save requestData into a file.

    If you need more flexibility - for HTTP Request samplers you can do it with Beanshell Listener like:

    1. Add Beanshell Listener to your Test Plan
    2. Put the following code into the Listener's "Script" area

      import org.apache.commons.io.FileUtils;
      
      String data = ctx.getCurrentSampler().getArguments().getArgument(0).getValue();
      int threadNum = ctx.getThreadNum();
      int loop = ctx.getVariables().getIteration();
      
      FileUtils.writeStringToFile(new File("request-" + threadNum + "-" + loop + ".txt"),data);
      

    You'll get files like request-x-y.txt generated in JMeter's "bin" folder where:

    • x - JMeter Thread Number
    • y - Current Loop Iteration (Thread Group level)

    See How to Use BeanShell: JMeter's Favorite Built-in Component article for more information on using Beanshell in JMeter tests.

提交回复
热议问题