JMeter Beanshell (Save Dynamic Values in CSV, Exce, Txt)

JMeter Beanshell (Save Dynamic Values in CSV, Exce, Txt)




Before we start, we need to do the correlation in JMeter, In the same correlation request add Beanshell Post Processor and place below code based on your need. 


1. Save Single Dynamic Value to the File

String val1 = vars.get("C_AllStatus");

FileWriter fstream = new FileWriter("/SystemPath/Ref-Numbers.csv",true);

BufferedWriter out = new BufferedWriter(fstream);

out.write(val1 +"\n");

out.close();

fstream.close();


2. Save Multiple Dynamic Values to the File


String value1 = vars.get("P_UserName");

String value2 = vars.get("P_CIFNumber");

String value3 = vars.get("C_rrNumber");

String value4 = vars.get("C_FinalStatus");

FileWriter fstream = new FileWriter("/SystemPath/Ref-Numbers.csv",true);

BufferedWriter out = new BufferedWriter(fstream);

out.write(value1 +"," + value2 + "," + value3 + "," + value4+"\n");

out.close();

fstream.close();

Comments

Popular posts from this blog

LoadRunner Tool

Selenium Performance Testing with JMeter and Selenium Grid

JMeter Integration with AppDynamics