Waiting for elements in the response goes to infinite loop

As you’re using the runner, the loop is coming from the postman.setNextRequest(pm.info.requestName) statement and that will keep going until you tell it to stop.

In this case, you’re setting the next request, to be the same request, so it’s just going to keep repeating that until the condition in the if statement is met.

Once the else if condition returns true, it goes down the other path and hits the postman.setNextRequest(null) which is the command to exit the workflow.

This would only loop if you’re using the Collection Runner to run the request.

There are lots of different ways/methods to loop through something, the for and while loops are the common ones but this wasn’t really needed here as the looping action is being done by the internal Postman function.

Hope that makes sense. :smiley:

1 Like