Posts

Showing posts with the label beanshell

Jmeter bean shell script, create file, read jmeter variable value, store script variable value into jmeter variable

Image
Hi All, Some times in JMeter scripting we need to store the output value in file or wanna show the run time  variable value in console window. OR we need to get the current JMeter script directory path. This can be achieved via scripting in Bean Shell Pre/Post Processor. Here I am using time and counter function of JMeter to create the file.In bean shell scripting we are reading the JMeter variables value and storing script variable value into JMeter variable or creating Jmeter variable Here is the  Bean Shell script : import org.apache.jmeter.services.FileServer; import org.apache.jmeter.services.FileServer; import java.util.Date; import java.text.SimpleDateFormat; SimpleDateFormat formatter = new SimpleDateFormat( "yyyyMMddHHmmss" ); String datetime = formatter.format( new java.util.Date() ); // Get current running counter value(C refrence name deifned in counter config element) String counter= vars.get("C"); // Get Jmeter variable value in bean she...