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 in developer tools) from chrome. I am having issues getting anything printed on console.

const logger = RequestLogger('',{        
    logRequestHeaders: true,   
    logRequestBody: true,
    logResponseHeaders: true,
    logResponseBody:    true
    ('My  test - Demo', async t => {
        await t.navigateTo('');//navigate to app launch
        await page_students.click_studentNameLink();//click on student name
        await t
            .expect(await page_students.exists_ListPageHeader()).ok('do something async', { allowUnawaitedPromise: true })       //validate list header
       await t
       .addRequestHooks(logger)     //start tracking requests
       let url = await page_studentList.click_tab();//click on the tab for which requests need to be validated

       let c = await logger.count; //check count of request. Should be 66

       await console.log(c);
        await console.log(logger.requests[2]);    // get the url for 2nd request

I see this in console:

    [Function: count]

Here is picture from google as an illustration of what I am trying to achieve. I navigate to and opened up developer tools> network tab. Then I clicked on store link and captured logs. The request URLs I am trying to collect are highlighted. I can get all the urls and then filter to the one I require.

enter image description here

The following, I have already tried

await console.log(logger.requests); // undefined
await console.log(logger.requests[*]); // undefined
await console.log(logger.requests[0].response.headers); //undefined
await logger.count();//count not a function

I would appreciate if someone could point me in the right direction?

64 thoughts on “Using testCafe 'requestLogger' to retrieve chrome performance logs fails”

Leave a Comment