Capture Console Logs

Hi again,

I’m trying to capture everything that is logged into console. I can save HAR file and parse network and get request/response/statuscode … but I need get output of console into file, or into variable, or to any point

I tried to do something like:

async function captureLogs(page, logger) {
  logger("Did I run?")
  page.on("console", (message) => {
exports.__esModule = true;
exports.captureLogs = captureLogs;

But this function just run (it is custom keyword), and does nothing else. (its js module) … Is there any way how to run this on background and listen on all events that happen? I run this keyword after the ‘New Page’ keyword is run.

I need information from console like:
Service worker registration complete
getting from server user
[Violation] ‘setTimeout’ handler took 228ms

etc… lot of information that are shown only in console, so the HAR file does not contains them.
Is there any way how to achieve this?

Depending on the Browser and libs u use, SeleniumTestability has keyword to acquire Browsers console logs.

Hm… Now I found out that this is not in the correct node of the forum. It it related to ‘Browser Library’

So my problem is with browser library itself. I can do it in selenium without any problems, but SeleniumTestability is not compatible with browser library. And as the Browser library is build uppon nodejs playwright I can’t find way how to just put some kind of listener to browser to capture logs.

thanks for reply