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
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
Great, you are half way through this challenge
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
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
@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!
HI! I faced the same issue (Page is correct | AssertionError: check param value: expected NaN to be above 0). I used the snippet in Pre-request script. My collection stopped running at page 403. The page’s number is stored as variable. But I still face the error. Can you help me? Thanks in advance
Hi @d.shapel, Welcome to the community!
The variable data is updated in the runtime and can be treated as current value.
But when the collection is tested, the variable is not initialized, and hence having null value. Which when interpreted by test script comes to NaN.
In such scenarios, you need to persist the value of variables before submitting the collection.
Hi @pranavdavar, thanks a lot for your help.
But I still face the same issue. I had saved the value of variable, submitted my collection and got the same fail: AssertionError: check param value: expected NaN to be above 0. Can I skip it and proceed with the challenge? Will it affect getting badge? What do you think?
https://www.postman.com/speeding-crater-37832/workspace/my-public-workspace/collection/14885870-ecc5479d-55a8-4886-8616-655e5573d154
I believe that the code that does this checking is broke.
The code that I used to check this value is below.
pm.test("Page is correct", () => {
let submitRequest = collection.item[1].item.find(req => { return req.name === "submit"})
pm.expect(submitRequest.request.url.query[0].key, 'check key value').to.equal("page")
pm.expect(parseInt(pm.request.url.query.get("page")), 'check param value').to.be.above(0)
pass += 1
})
Updating the value check properly checks the value of the “page” parameter. The previous
submitRequest.request.url.query[0].key
might have worked in the past but I believe it is broken as of right now.
I have been trying all the suggestions mentioned here. I made sure to initialize from 0, persist the variable, used the parseInt method. I got 403 passing tests until the fail and page count showed 404, that isn’t working, neither are nearby values like 403
Hey @payload-astronaut-99, welcome to the community
You are almost near to your successful submission, but it will be amazing if you can help with some more details
How can we persist variables ? go to the variables and click persist or how can we do in script?
Did you get it to work? I am facing the same thing
I am getting this error when i set it as environment var also
I found a solution !!!
delete row 48 from submit test , test Pass , then return the line Ctr + Z , otherwise something is wrong