Ekaterina Poligon
Ekaterina Poligon

Reputation: 5

Does anybody knows how to save variables in file for each sampler in Jmeter?

I'm sending websocket requests(json) and get some responses from server. Than I'm saving in variables some parameters' values from derived response(using Regular Expression Extractor). How can I save values of this variables in file for each sampler?

Upvotes: 0

Views: 503

Answers (1)

Dmitri T
Dmitri T

Reputation: 168122

  1. Add a Beanshell PostProcessor after Regular Expression Extractor.
  2. Put the following code into PostProcessor's "Script" area

    import org.apache.commons.io.FileUtils;
    
    String sampleName = prev.getSampleLabel();
    String var = vars.get("myVar");
    FileUtils.writeStringToFile(new File(sampleName + ".txt"), vars.get("myVar"));
    

Where:

See How to use BeanShell: JMeter's favorite built-in component guide for more details on Beanshell scripting in Apache JMeter.

Upvotes: 1

Related Questions