Reputation: 5
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
Reputation: 168122
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:
prev
- stands for parent SampleResultvars
- JMEterVariables instance for current thread groupFileUtils
- org.apache.commons.io.FileUtils class instanceSee How to use BeanShell: JMeter's favorite built-in component guide for more details on Beanshell scripting in Apache JMeter.
Upvotes: 1