Your question may already have an answer on the community forum. Please search for related topics, and then read through the guidelines before creating a new topic.
Here’s an outline with best practices for making your inquiry.
My question:
How do we update/reset the variable after each iteration?
Details (like screenshots):
I am trying to use postman to do data testing on some pagination endpoints. Also, using data file to run iterations. Issue is, variable is not getting reset after iteration is finished. I am using postman’s echo endpoint as POC.
My scenario: I want to run api once. Depending on record count I get, I want to jump to last page, and validate the final page records. For this I am trying to update the pageNumber in tests and then re-running the api with updated values.
Here is the data file that I am using in runner,
[ { “pageNumber”: 0, “pageSize”: 2 }, { “pageNumber”: 0, “pageSize”: 5 }, { “pageNumber”: 0, “pageSize”: 10 } ]
Steps:
- In postman runner, select data file. This should give 3 iterations.
- Save response, so we can validate the executions
- Run Postman
Iteration 1 runs fine. pageNumber value is updated correctly. Ideally, for iteration 2, pageNumber value should be reset to 0, as that’s what I provide from my data file. But postman persists the previously calculated value, and does not update this value.
URL = https://postman-echo.com/get?pageNumber={{pageNumber}}&pageSize={{pageSize}}&totalRecords=46
Below is the execution log from console. Highlighted in red, pageNumber should get updated for new iteration, but it doesn’t.
Could someone please suggest what am I doing wrong here? or if I am missing out something wrt how variable update works with data files.
How I found the problem:
While testing the actual API. So I created a sample using postman echo api, and replicated the issue.
I’ve already tried:
Moving variables to environment and collection, but no luck.