Day 16: Pagination

For one of the test Assertion I am getting this error

Page is correct | AssertionError: check param value: expected NaN to be above 0

Screenshot

Passing the page value from the collection Variable

@akshaysakhk Welcome to the community :partying_face:

Great, you are half way through this challenge :rocket:

This is why because you are setting the variable directly as “pages”.

Here page is stored as string and you need to use parseInt() method before incrementing the variable.

I hope this will solve your problem :raised_hands:

Hi Pricilla,
Thanks for the Help.

I am using this code to set the page number

var page_count=parseInt(pm.collectionVariables.get(“page”));
page_count++;
pm.collectionVariables.set(“page”, page_count);

Even after using parseInt() Function getting the same error

In console
for the Submit Request i am getting the Integer 2511
GET https://api.getpostman.com/collections/14039334-a884d51c-4451-4552-9f45-60c5b78af01b?page=2511

@akshaysakhk Can you please try with the below snippet:

pm.collectionVariables.set("page", parseInt(pm.collectionVariables.get("page")) + 1);

same here :frowning:

@bpricilla I tried with your snippet (should I use it for the Pre-request Scripts of the ‘xkcd’ request, right?) and it works fine for setting the page number. Unfortunately I’m still getting:

Page is correct | AssertionError: check param value: expected NaN to be above 0

on the ‘submit’ request

Thank you!

Try to not use the variable {{page}} and put the page number normally:

Worked for me!