Write extracted data to a file using jmeter

Just solved a similar problem. After getting the data using a regular expression extractor, add a BeanShell PostProcessor element. Use the code below to write the variables to a file:

name = vars.get("name");
email = vars.get("email");

log.info(email);  // if you want to log something to jmeter.log file

// Pass true if you want to append to existing file
// If you want to overwrite, then don't pass the second argument
f = new FileOutputStream("/my/file/path/result.csv", true);
p = new PrintStream(f); 
this.interpreter.setOut(p); 
print(name + "," + email);
f.close();

Leave a Comment