I have a BSF post-processor added to a sampler.
The script in the post-processor is:
var array = JSON.parse(prev.getResponseDataAsString());
array.forEach(function(object)
{
OUT.println("patient_id: "+object.patientId);
OUT.println("fname: "+object.fname);
OUT.println("lname: "+object.lname);
});
now i want to use object.patientId, object.fname, object.lname values as parameters in another request's parameters.
E.g.
Thread Group
- Sampler1
BSF Post-Processor
- Sampler2
I want to use the variables in the BSF Post Processor's javascript of Sampler1 as parameters in Sampler2. Is that possible?
Easily: BSF PostProcessor provides read/write access to Jmeter Variables / Properties:
In the simplest case you can use
in your BSF PostProcessor to set the variables, and then get they values like
or
But since you are extracting ALL the records in foreach loop at once you cannot use this way.
In this case you have to better use something like the following: write all the records values extracted in foreach loop into csv-file, and then use e.g. CSV Data Set Config to read records one-by-one in loop and use values along with your Sampler2:
...As well, if I find another, better way, I'll be glad to know about it.