2

I have 100 request in collection runner and there are some request that will execute only on some condition. Actually when we run the postman collection it will execute all request 1 by 1.

In my case there are 10 requests in collection runner and dont want to execute it in normal follow only trigger some request just on specific condition. Is there any why I can prevent these request not no execute in normal run but should available in collection runner will execute on just specific condition

Mehran Shafqat
  • 422
  • 2
  • 5
  • 16
  • 1
    Postman does not have enable/disable feature as per my knowledge but it allows branching and looping over the requests. Using postman.setNextRequest you can set which request to execute next. See official documentation at: https://learning.getpostman.com/docs/postman/scripts/branching_and_looping/ – Ajinkya Jul 06 '19 at 22:56
  • look like postman very limited in such a cases and postman.setNextRequest not doing anything new it just call the request that we call and ignore the next request and continue other call in sequence way. Very limited in Automation part. – Mehran Shafqat Jul 07 '19 at 09:03
  • Nothing stopping you submitting a feature request and explain your usecase, it's a community driven project so useless you tell them, they won't know. :) https://github.com/postmanlabs/postman-app-support/issues – Danny Dainton Jul 07 '19 at 14:56

1 Answers1

1

In my opinion you can achieve this already.

I will user some flag set in environment variables to check if it is your "normal" run or not

And next use this flag in test script to set next request to be called:

if (pm.environment.get("normal_run"))
    postman.setNextRequest("Request name 10");
else
    postman.setNextRequest("Request name 13");

And set this part of code in every request before request you need to be skipped. postman.setNextRequest() is executed in the end of request call, so you can place it anywhere in Pre-request Script.

Finally, use one environment for your normal run, and second environment for another.

Nikita Popov
  • 896
  • 10
  • 19
gregPi
  • 118
  • 1
  • 7