How to get the next request without hardcoding test name?

I am using the postman.setNextRequest method to repeat the test until the condition is met. I use the pm.info.requestName as a parameter for the current request. When the condition is not met, I want to set the next request to the one right after. Currently I’m hardcoding the request name. Is there a way to get that value dynamically?

Hi @ameenjafferie. Welcome to the Postman Community.

I’m not sure there is a way to do that. However, you can use pm.execution.skipRequest to skip the current request running in the pre-request script if the condition is not met.

If the condition is met, then you shouldn’t need to do anything.

You just don’t set anything with setNextRequest().

The default behaviour is that the next request in the collection should just run as normal.

2 Likes

Thanks! Good to know!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.