Tuesday, October 8, 2013

Jmeter Variables/Correlated values to CSV file using Bean shell scripting in windows


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

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 while values sending to csv file:
1. Overwriting File for each Correlated value for each user
2. Appending Value for each time

1.Overwriting File for each Correlated value for each user:
SID_J=vars.get("SID");

f = new FileOutputStream("C:\\OfficeWork\\Java\\id.txt"); //Windows

p = new PrintStream(f);
this.interpreter.setOut(p);
print(SID_J);
f.close();

2.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("C:\\OfficeWork\\Java\\id.txt",true); //Windows
p = new PrintStream(f);
this.interpreter.setOut(p);
print(SID_J);
f.close();

No comments: