Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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.

Steps:

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

    Image Modified

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

    Code Block
    languagejs
    titlepushValueToArray
    linenumberstrue
    (function(){
    	var aFunction = function(res, opts, arr, val){
    		if(!arr) arr = [];
    		arr.push(val);
    		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.

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

...