CodeceptJS icon indicating copy to clipboard operation
CodeceptJS copied to clipboard

GrabBrowserLogs Showing Previous Logs Even After Clearing The Console

Open ninpop25 opened this issue 8 years ago • 3 comments

I am running Automation test cases on Server Machine (Windows 10) Via Jenkins and all I want is that when I load my test page then I click on some button and that after that click action on button records some log in console in(Info) and I want to check the occurrence and count of that log.

@APshenkin @DavertMik @BLouzada : Please help me in this

Issue is that when I load my test page,I have used console.clear(); in I.ExecuteScript(); of codeceptjs and after that I click on Button and after that I am using GrabBrowserLogs(); and print the log..but the printed values are not the one that should come after click on Button but its the default one before even using console.clear(),I mean as per me when my test page loads then only the GrabBrowserLogs(); records the log and give me result,its not getting cleared after using console.clear()

What do you get instead?

Provide console output if related. Use --verbose mode for more details.

# paste output here

Provide test source code if related

// templatePage.openTemplateDirect("FVAutomation%2345670");
    I.waitForVisible({ xpath: '//input[@data-fv-xd-ctrlid="btnPeoplePickers"]' }, 60);
    I.executeScript(function () {
        console.clear();
    });
      
    I.click({ xpath: '//input[@data-fv-xd-ctrlid="btnPeoplePickers"]' });
    let logs = yield I.grabBrowserLogs();
    console.log(JSON.stringify(logs))
});

Details

  • CodeceptJS version:
  • NodeJS Version:
  • Operating System:
  • Protractor || WebDriverIO || Nightmare version (if related)
  • Configuration file:
# paste suite config here

ninpop25 avatar Jan 16 '18 17:01 ninpop25

Unfortunately this is just how the WebDriver.io api works. I believe the logs retrieved by the I.grabBrowserLogs (i.e. webdriver.io api), will only be cleared when the I.grabBrowserLogs is called.

So if you want to clear the log, then just call I.grabBrowserLogs() instead of using the I.executeScript function.

It is not ideal, but just the way things are. The browser logs is not part of the webdriver specification, so different tools handle it differently.

reubenmiller avatar Jan 27 '18 18:01 reubenmiller

So I think we can close this issue as it is more an issue/quirk with webdriver.io and not Codeceptjs itself.

reubenmiller avatar Jan 27 '18 18:01 reubenmiller

@reubenmiller : thanks :)

ninpop25 avatar Jan 28 '18 07:01 ninpop25