Hello @danny-dainton and thank you for your reply.
I’m sorry I did not add some context as I thought the original topic was already giving some. Let’s clarify the content here.
The context
I have a collection with some requests. Into one of those requests, there is a Pre-request script defined, and this pre-request script is programmed in order to have the request to behave differently from whether I just send the request by clicking the “Send” button, or if the request is executed through a collection run I either started with the “Run” button or using Newman to run my collection. This context is what I want, and what I already have, but…
To programmatically know the behavior I want the request to follow, my pre-request script is something like this:
if (postman.__execution.cursor.length > 1) {
// Behave like we are in a collection run.
} else {
// Behave like we click on "Send" button.
}
Like I said, this perfectly works and does exactly what I want. But there are 2 problems :
Problem 1
First problem is that using postman global variable is deprecated, so I would like to have another variable that does exactly the same than postman.__execution.cursor.length without relying on a deprecated variable. To be clear, I want to replace the pre-request script I just described above with
if (variable.I.could.use.to.do.the.same > 1) {
// Behave like we are in a collection run.
} else {
// Behave like we click on "Send" button.
}
Problem 2
Second problem is that when I run the collection using Newman, I can read this log message when my pre-request script is executed:
┌
│ 'Using "postman.setNextRequest" is deprecated. Use "pm
│ .execution.setNextRequest()" instead.'
└
And to be clear: I replicated this problem by running a collection of a single request only containing postman.__execution.cursor.length in its pre-request script via Newman, nothing more, nothing less, and the log message was triggered.
Expectations
The second problem is creating confusion because it is said that postman.setNextRequest was called, while this is not true, it was postman.__execution.cursor.length. But the first problem is maybe the one I’m expecting a solution the most: as soon as I have a non-deprecated variable that does the same, the second problem should not occur anymore.
I hope I was clear enough. If I wasn’t, please feel free to tell me which part exactly on my message you don’t understand so I could enlight you.
Have a nice day