TestProject Forum

Validate requests in the Chrome Dev tools console

Hi,

How I can check in my TestProject test if there are unnecessary requests that are performed by the application, that are visible only in the Chrome Dev tools console ?

For example, perform validation that URL of the current request is not the same as URL of the previous request.

Hi @Igors_danosaites ,
You can use the action ‘Get network logs as JSON’, and then parse the JSON in any method you like, for example, validate that request is present or make sure it is present but only once is definitely possible but require a bit more steps, this is how I did it,
First I captured the network logs into a parameter:

image

Then I parsed the logs using ‘Get value from JSON using JsonPath’:

Now inside the result, I have a list with all the request URLs. you can do any manipulation you want on that list.
You can use this website to evaluate your Jayway Json expression

I made sure it contains a request like this:

To make sure a request does not appear more than a specific amount of times I used this Javascript action with validation in the end:

You can copy the Javascript code from here:

var data = {Results};
var count = (data.join().toString().match(/www.airbnb.com/g)).length;
return count;

Make sure to replace {Results} with parameter, and make sure to change the expression to match your own website match(/Your End Point Here/g) use the /g flag to match all.

Let me know if you have any questions. feel free to tag me (@Amit.Lacher)