Extracting variables in a loop

This guide will help you to extract variables of a test case having a loop.

Suppose we have a test case to validate the Add contact API and we are executing this test case in a loop.

And we want to extract the contact ids and names of all the newly created contacts and we want to store them in array say contactIds and names respectively.


  1. First create a utility method say pushValueToArray like this.

    You may use the below code for the utility method `pushValueToArray`

    	var aFunction = function(res, opts, arr, val){
    		if(!arr) arr = [];
    		return arr;
    	return aFunction;
  2. Then in variable extractor tab of the test case, extract the desired properties of the response, as you do normally for the current iteration. In this sample demonstration, we want to extract the _id property of the API response.

  3. Now, for each extracted property, create another variables e.g. plural version of variables and invoke the utility method like this.

    1. In pushValueToArray, first argument ({{contactIds}} or {{names}}) must not be enclosed with double quotes.