REST Response: executing several teststeps for every object in REST response. How?
GOAL
Execute several Test steps (GET requests) for every Object in a REST Query Response.
SCENARIO
I want to build a Functional Test
1. Execute GET Query request that will have several results in the response (there is a "count" element in the response with the number of results)
2. For every result in the response i want to execute several GET requests to obtain the details of each Result
WHAT I AM TRYING
1. Store the value of "count" in a Property so i know how many loops i have to perform
2. Define another Property 'loopCount' that will count the number of loops
3. Use the property 'loopCount' to refer to elements of a certain Result
Example:
In one of the Test Steps a Request proprerty is used that refers to the first Result:
${Query Zaken - GET by bsn#Response#$['results'][0]['uuid']}
I was thinking to make this dynamically using the 'loopCount' property.
${Query Zaken - GET by bsn#Response#$['results'][<some reference to property loopCount>]['uuid']}
QUESTIONS
1. Is this the way to go or are there nicer/better solutions possible?
2. How can i make a dynamically reference to a certain Result in the list with Results in subsequent GET requests?
Kind regards,
Maarten
MRutten ,
using JSON DataSource might help here.
An example for illustration (using famous Pet store use case from https://petstore3.swagger.io/ )
How it works:
- GetPets: We get all pets with a GET query
- PetsDataSource: Parsing the GetPets response into a Data Source
- GetPetDetail: Using the value within a request
- Data Source Loop: Taking another set of values from Data Source and jump to GetPetDetail.
There may be more complex processing between GetPetDetail and the end of the loop if needed.
Here's the configuration of the Data Source:
Best regards,
Karel
Daag meneer MRutten , 🙂
${loopCount} is wrong.
Use ${#Properties#loopCount}.
After ${# you must wirte the location, in your case the properties test step. On the end you write the name of the property. In your example is the name of the property #loopCount}.Best wishes, Giovanni