Skip to content
This repository was archived by the owner on Jul 30, 2022. It is now read-only.
This repository was archived by the owner on Jul 30, 2022. It is now read-only.

Clear performance logs #46

Open
Open
@skullz03

Description

@skullz03

HI,

There is a useful example for capturing performance logs in your repo(Thanks for that). I am trying to make use of it by logging my network calls to a text file. However, I am noticing that it preserves call from my previous pages as well and therefore when I filter the calls, I see more than expected number of network calls.
Is there a way to clear the performance calls before I execute my last test step and collect logs? Here is my code. Any suggestion would be helpful

After(async function(scenario) {
    console.log("After Hook");
    if (scenario.result.status === Status.FAILED) {
        // screenShot is a base-64 encoded PNG
         const screenShot = await browser.takeScreenshot();
         this.attach(screenShot, "image/png");
     }
     await console.log("After if");
     let browseLogs = await browser.manage().logs().get('performance');
    //  let browseLogs = await 

     await console.log(browseLogs.length);
     browseLogs.forEach(async (logE)=> {    
                    
        var message = await JSON.parse(logE.message).message;  
        if(message.params.response.url.includes(ADOBE_ANALYTICS_NETWORK)) 
          {
            await fs.appendFile(logs, JSON.stringify(message), (err) => {
                if(err) throw err;            
             });  

        }   
        
});
});

These are my config.ts

 capabilities: {
        'browserName': 'chrome',
        'chromeOptions': {
          'perfLoggingPrefs': {
            'enableNetwork': true,
            'enablePage': false
            //'enableTimeline': false
          }
        },
        loggingPrefs: {
          performance: 'INFO',
          browser: 'ALL'
        }
      },

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions