Ask a Question

Store a series of Id's in a property while iterating in a data source loop

SOLVED
atariqnadra
Member

Store a series of Id's in a property while iterating in a data source loop

I have a test step within a Data Source Loop that creates test users. Each request to create a user returns the user id in the response. I want  to store all Id's while creating the users so that I can iterate over them one by one later in the test.

5 REPLIES 5
LennSar
Contributor

That's funny, I just posted a very similar question. I think the solution is some fancy groovy script that takes the response ID, stores then handles the "later iteration" stuff as well. Curious whether there is a non scripting approach to get this done.

ChrisAdams
Champion Level 2

Hi,

Have a look at the support material for the datasink step.  This allows you to save data to file.  You can have a datasink step inside the loop of your data-driven test.

The file produced by the data sink can then be used as the datasource for another loop later in your test.

If you search this forum, you'll find some other solutions I posted about datasource loops and datasinks.

atariqharri
Occasional Contributor

Can you provide a link to your questions please @LennSar 

atariqharri
Occasional Contributor

It only stores the value from the latest loop. @ChrisAdams 

 

Edit: your solution works as you explained, thanks!

 

ChrisAdams
Champion Level 2

Hi,

 

That depends entirely on how you set up the datasink step and where you place it.

 

To capture values from each iteration, the datasink needs to be 'inside' the loop.  I typically place it immediately before the datasource loop so that it is the last step inside the loop.

 

You can also set-up the datasink such that it overwrites or appends data.  Overwrite means that when the test starts, the datasink is emptied.  Append will just keep on throwing data into your file.  For your needs, I'd suggest overwrite.

 

If you're still having issues, then some screenshots of your test would be useful.

 

 

cancel
Showing results for 
Search instead for 
Did you mean: