I am pretty new to testing with JMeter. I have a JSON block that I would like to populate with values from three arrays that I created from a previous GET request. The structure is similar to this:
"books": [
{
"publisher": ${publisherName}, //variable but it's the same for all items in this request
"ISBN": ${isbn_1}, //the next three are from from 3 different arrays
"Price": ${price_1},
"Publisher": ${publisher_1},
"Static Value that doesn't change": 100
},
{
"publisher": ${publisherName}, //variable but it's the same for all items in this request
"ISBN": ${isbn_2}, //the next three are from from 3 different arrays
"Price": ${price_2},
"Publisher": ${publisher_2},
"Static Value that will be the same for all items": 100
},
],
Is there a way to loop through adding the blocks dynamically so I can send all of these items in a single request?
2
Answers
I assume you have 3 different arrays with same size for
ISBN
,Price
,Publisher
. You write code toJSR223 Pre-Processor
You can do it using any suitable JSR223 Test Element and Groovy language
Without seeing how your "arrays" look like it’s hard to come up with a comprehensive solution, the JSON structure can be created like:
The generated value can be stored into a JMeter Variable like:
and used as
${payload}
later on where requiredMore information: