Day 08 Run a collection- unable to get french user

Unable to get french user.


Can someone please help me .

In the params you need you need to put on the key value ‘nat’ and in the value ‘fr’.

You aren’t targeting the element correctly.

Hint: The first element in the response is an array called results.

When you are trying to target elements in responses, the advice is to console log the response and then target the elements one level at a time until you get to the element you need. Once you have managed to console log the element correctly, you should then be able to craft the test\assertion.

If you did this, you would find that responseBody.nat is returning undefined (as its not dealing with the results array).

2 Likes

Able to solve the problem it’s working fine in Frech user request.



but upon submission one of the tests is failing.

You have the “nat” parameter with multiple entries, which is meant to produce a random user based on those nationalities.

However, you have just got French twice.

The examples in the randomuser documentation show the letters in uppercase or lowercase (but I have tested this and it also appears to take mixed case as well).

However that is sort of irrelevant as the test in the Postman submit is specifically checking that the nat is either “FR” or “fr”, therefore you need to update your “get french user” request and only have one value in the nat parameter and it needs to be either “FR” or “fr”.

On a side note, your code in the “get french user” request could do with some refactoring.

You parse the response twice, once in each test. I would recommend that you parse the response once as the first line in the test tab (outside of the tests), which you can then use in each test. Which will reduce your code by 2-3 lines.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.