Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

any way to capture javascript console logs? #406

Closed
divinity76 opened this issue Aug 16, 2022 · 2 comments
Closed

any way to capture javascript console logs? #406

divinity76 opened this issue Aug 16, 2022 · 2 comments

Comments

@divinity76
Copy link
Contributor

is there any way to capture javascript console logs? like if i navigate to a page that contains javascript errors, is there any way to capture those javascript errors on the php side?

@enricodias
Copy link
Member

Register this listener before navigating to a page:

$page->getSession()->on('method:Runtime.consoleAPICalled', function (array $message): void {
    if ($message['type'] === 'log') {
        \var_dump($message);
    }
});

The type could be any of the following:

log, debug, info, error, warning, dir, dirxml, table, trace, clear, startGroup, startGroupCollapsed, endGroup, assert, profile, profileEnd, count, timeEnd

Reference: https://chromedevtools.github.io/devtools-protocol/tot/Runtime/#event-consoleAPICalled

@divinity76
Copy link
Contributor Author

Perfect! thanks

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

No branches or pull requests

2 participants