Is there a way to access the iteration number in Postman REST Client?

I am using postman for API testing. I am running a large number of tests and I want to print the iteration number to the console on some of them. Is there a way to get the iteration number as an environment variable?

+3


source to share


3 answers


Now it's possible! You can access a variable iteration

in the same way as other variables, for example responseBody

.



+1


source


I don't know if there is an internal way to get the iteration number, but I believe you should keep track of this number through the code yourself. Here's a quick snippet of code:

var value = environment.count;
value++;
postman.setEnvironmentVariable("count", value);

      



If you put this in a pre-query editor or a test collection editor that you are sure will run once per iteration, it will effectively keep track of the iteration count.

+1


source


According to the Mail User Reference , pm.info.iteration is the value of the current iteration being performed.

Example:

console.log(pm.info.iteration);

      

+1


source







All Articles