Tuesday, October 8, 2013

Jmeter Variables/Correlated values to CSV file using Bean shell scripting in MAC, Linux and Unix

Step 1. Add thread group
Step 2. Add your "Http Sampler" with http request
Step 3. Use "Post processor" of "Regular expression Extractor" as a child to your "Step 2
        Here SID is the Dynamic value
Step 4. Again Use "Post processor" of " BeanShell PostProcessor" as a child to your "Step 2

Write the below code to get Correlated values to CSV file.


We have two Options :
1. Overwriting File for each Correlated value for each user
2. Appending Value for each time

Overwriting File for each Correlated value for each user:
-------------------------------------------------------------------------

SID_J=vars.get("SID");
f = new FileOutputStream("/Users/mcheepati/jmeter/results.csv");
p = new PrintStream(f);
this.interpreter.setOut(p);
print(SID_J);
f.close();

Appending Value for each time :
------------------------------------------------------

SID_J=vars.get("SID");
// 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("/Users/mcheepati/jmeter/results.csv",true);
p = new PrintStream(f);
this.interpreter.setOut(p);
print(SID_J);
f.close();

No comments: