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

Clear performance logs #46

Open
skullz03 opened this issue Aug 10, 2018 · 0 comments
Open

Clear performance logs #46

skullz03 opened this issue Aug 10, 2018 · 0 comments

Comments

@skullz03
Copy link

skullz03 commented Aug 10, 2018

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'
        }
      },

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant