:::: MENU ::::

Software testing enthusiast.

In this tutorial I want to share my method to iterate a request in postman collection, so it will run several times.

To simulate API response body I create an API mock using mocky. To see my mock API you can click here.

Without a further ado I will demonstrate how to loop a postman request.

  1. In collection level click Triple dot >> Edit >> Variables
Edit variables

2. In tab Variables tab, type in type in count with current value 5, then click Update. This step will create new variable in collection level.

Collection variables value

3. Create new request. For this simulation I will use request from this story. But I will modify the test script. In the test script add script as follows.

var currentCount = pm.collectionVariables.get("count")
if (currentCount > 0){
currentCount = currentCount -1 ;
pm.collectionVariables.set("count", currentCount);
postman.setNextRequest("Get books detail (loop)");

4. Save request and run collection. To make it works, one can’t run the test by clicking “Send” button. We must run it using collection runner.

Collection runner

5. Run it and Voila!! we’ll get another 5 request running.

Test result

Thank you for reading my story. Hope it will helps you.

Follow me on

Facebook: https://www.facebook.com/mydoqa/

Instagram: https://www.instagram.com/mydoqa/

Twitter: https://twitter.com/MydoQa


Post a Comment

Find this blog interesting? Follow us