CefSharp F12打开DevTools查看console
Posted xuejianxiyang
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CefSharp F12打开DevTools查看console相关的知识,希望对你有一定的参考价值。
winform嵌入chrome浏览器
1.nuget安装cefsharp
2.实例化浏览器
private void Form1_Load(object sender, EventArgs e)
{
ChromiumWebBrowser b = new ChromiumWebBrowser("http://localhost:57531/views/Map/scene.html");
this.Controls.Add(b);
b.Dock = DockStyle.Fill;
b.KeyboardHandler = new CEFKeyBoardHander();
}
3.响应F12打开控制台console
public class CEFKeyBoardHander : IKeyboardHandler
{//https://bbs.csdn.net/topics/392375553
public bool OnKeyEvent(IWebBrowser browserControl, IBrowser browser, KeyType type, int windowsKeyCode, int nativeKeyCode, CefEventFlags modifiers, bool isSystemKey)
{
if (type == KeyType.KeyUp && Enum.IsDefined(typeof(Keys), windowsKeyCode))
{
var key = (Keys)windowsKeyCode;
switch (key)
{
case Keys.F12:
browser.ShowDevTools();
break;
case Keys.F5:
if (modifiers == CefEventFlags.ControlDown)
{
//MessageBox.Show("ctrl+f5");
browser.Reload(true); //强制忽略缓存
}
else
{
//MessageBox.Show("f5");
browser.Reload();
}
break;
}
}
return false;
}
public bool OnPreKeyEvent(IWebBrowser browserControl, IBrowser browser, KeyType type, int windowsKeyCode, int nativeKeyCode, CefEventFlags modifiers, bool isSystemKey, ref bool isKeyboardShortcut)
{
return false;
}
}
From: https://www.cnblogs.com/xuejianxiyang/p/9981398.html
以上是关于CefSharp F12打开DevTools查看console的主要内容,如果未能解决你的问题,请参考以下文章
chrome devtools protocol——Web 性能自动化