Day 26th -parse html response-I am able to create an array and store the values of the response in an array it passes individually when i run the test case. But when i run it in submit the test case gets failed stating that cannot read property āfindā of undefined. Can anyone help me out .
Can you double check that your collection variable is being created and that the value is persisted both the āinitial valueā and ācurrent valueā columns?
When I recreated your solution, I got a different error: āJSONError: No data, empty input at 1:1 ^ā. After I persisted the ālinksā collection variableās value to be in both the initial and current columns, the validation test passed. However, when I delete the collection variable altogether, I get the error youāre showing, so it seems like maybe your collection variable isnāt being created. Hope this helps!
Hi! Could you expain why do you use JSON.stringify in this case: pm.collectionVariables.set(ālinksā, JSON.stringify(links)) ?
When variable ālinksā is already an array? Why would you make it as a string?
But I see that when setting this array to collection variable Postman does not see it as array. How come?
You need to stringify() arrays when storing them as collection\environment variables and then JSON.parse() them when retrieving or they end up being treated as strings not arrays.
Itās the same principle when parsing the response. If you didnāt parse it, and just retrieved the body it would just be a JSON object wrapped in a string.