Skip to content Skip to sidebar Skip to footer

Using Testcafe 'requestlogger' To Retrieve Chrome Performance Logs Fails

This is in continuation of this thread: Is there a way in TestCafe to validate Chrome network calls? Here is my testCafe attempt to retrieve all the network logs(i.e. network tab i

Solution 1:

You are using different urls in your test page ('https://appURL.com/app/home/students') and your logger ('https://studenthome.com'). This is probably the cause. Your Request Logger records only requests to 'https://studenthome.com'.

In your screenshot I see the url 'http://store.google.com', which differs from the logger url, so the logger does not process it.

You can pass a RegExp as a first arg of the RequestLogger constructor to all requests which match your RegExp.

I have created a sample:

import { RequestLogger } from'testcafe';

const logger = RequestLogger(/google/, {
    logRequestHeaders:  true,
    logRequestBody:     true,
    logResponseHeaders: true,
    logResponseBody:    true
});

fixture `test`
    .page('http://google.com');

    test('test', async t => {
        await t.addRequestHooks(logger);

        await t.typeText('input[name="q"]', 'test');
        await t.typeText('input[name="q"]', '1');
        await t.typeText('input[name="q"]', '2');
        await t.pressKey('enter');

        const logRecord = logger.requests.length;

        console.log(logger.requests.map(r => r.request.url));
    });

Post a Comment for "Using Testcafe 'requestlogger' To Retrieve Chrome Performance Logs Fails"