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

Capture Devtools Console output #1130

Closed
avspeed opened this issue Jul 18, 2015 · 7 comments
Closed

Capture Devtools Console output #1130

avspeed opened this issue Jul 18, 2015 · 7 comments

Comments

@avspeed
Copy link

avspeed commented Jul 18, 2015

Hello,

Is it possible to capture the Dev tools console output and display it in my .NET app ?

Thanks

@jornh
Copy link
Contributor

jornh commented Jul 18, 2015

There is nothing specific for it in CefSharp. But as Devtools is implemented in JavaScript it's "just" a matter of injecting some JS and using EvaluateScriptAsync.

So it's more of an upstream CEF/Chromium question and you have to dig around there to see if there's a sensible API exposed. A few starting points:

  • https://developer.chrome.com/extensions/devtools probably isn't available in CEF as it's an Chrome Extension API (and those are generally only available in Google Chrome - not the open source Chromium)
  • https://developer.chrome.com/devtools/docs/debugger-protocol via e.g. C# WebRequestmight be an alternative depending on what you really want/need
  • Lacking a proper stable API simply dig around the DOM of the console and hack something. Though this may sound terrible the good part is that you are in complete control of when you push upgrades - still you have to verify each time :-(

@amaitland
Copy link
Member

For basic console messages there is of course https://github.com/cefsharp/CefSharp/blob/master/CefSharp/IWebBrowser.cs#L14

@jornh
Copy link
Contributor

jornh commented Jul 18, 2015

Good catch @amaitland 😄 I completely forgot about that one!

@avspeed
Copy link
Author

avspeed commented Jul 18, 2015

Exactly what I need - Thank you!

@avspeed avspeed closed this as completed Jul 18, 2015
@amaitland
Copy link
Member

The DevTools reference in the initial question was a little misleading. Initially I read the question the same way @jornh did 😄

@aslamiqbal
Copy link

@amaitland

For basic console messages there is of course https://github.com/cefsharp/CefSharp/blob/master/CefSharp/IWebBrowser.cs#L14

Awesome. I was looking for this all over the internet full day.

@ichengzi
Copy link

browser.ConsoleMessage += (s, e) =>
{
    Logger.Debug("chrome_console", $"{e.Message}\t{e.Source}");
};

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

No branches or pull requests

5 participants