How to verify result when sendNextRequest

I am running sendNextRequest and try to set global variable with value and try to verify after running twice…

but each time value not verify

can anyone give example for that?

Hi @CV-JigneshP - welcome to the Postman Community! :slight_smile:

Could you provide more details on your issue? Screenshots/code snippets can help us troubleshoot. What other solutions have you attempted so far?

i need a example for Chain tests together to create test suites in postman

how it’s work? and also when i use sendRequest into for loop it’s run once only…

i need a example for sendRequest in for loop

Do you absolutely need to run sendRequest as a script?

Could you make the request a proper Postman request as part of your collection?

Pre-request script:

var pPartids = pm.environment.get(“envPartids”);

var pQuantities = pm.environment.get(“envQuantities”);

if(!pPartids){

pPartids = [516,516];

}

if(!pQuantities){

pQuantities = [1,1];

}

pm.environment.set(“envPartids”,pPartids);

pm.environment.set(“envQuantities”,pQuantities);

Tests
var pPartids = pm.environment.get(“envPartids”);

var pQuantities = pm.environment.get(“envQuantities”);

console.log(“pPartids length:”+pPartids.length);

var currentPartID = pPartids.shift();

var currentQuantity = pQuantities.shift();

console.log(currentPartID+currentQuantity)

pm.environment.set(“PartID”,currentPartID);

pm.environment.set(“Quantity”,currentQuantity);

var tpartids = pm.environment.get(“envPartids”);

console.log(“part length:”+tpartids.length);

for(var i=0;tpartids.length > 0;i++)

{

console.log("i:"+i);

postman.setNextRequest("Verify User should able to add part into cart");

pm.test("Status code is 200 in add same part into cart", function () {

    pm.response.to.have.status(200);

});

var jsonData = JSON.parse(responseBody);

console.log("quantity: "+jsonData.Details[i].Quantity);

var currentPartID = pPartids.shift();

pm.environment.set("PartID",currentPartID);

pm.environment.set("envPartids",pPartids);

var currentQuantity = pQuantities.shift();

pm.environment.set("Quantity",currentQuantity);

pm.environment.set("envQuantities",pQuantities);

}

here is example

when i try above code it’s run only once…