Open Google Chrome developer tool console while C# selenium test is running, or read it programmatically

删除回忆录丶 提交于 2019-12-05 08:53:26
Avishay

To open chrome console:

var inSim = new WindowsInput.InputSimulator()

inSim.Keyboard.KeyDown(WindowsInput.Native.VirtualKeyCode.LCONTROL);
inSim.Keyboard.KeyDown(WindowsInput.Native.VirtualKeyCode.LSHIFT);
inSim.Keyboard.KeyPress(WindowsInput.Native.VirtualKeyCode.VK_J);
inSim.Keyboard.KeyUp(WindowsInput.Native.VirtualKeyCode.LSHIFT);
inSim.Keyboard.KeyUp(WindowsInput.Native.VirtualKeyCode.LCONTROL);
  • What you can do: take a snapshot of the browser (including the opened console).
  • What you cannot do: use the webDriver (it will crash the test, but if you close the console, the same way you opened it, you will be able to continue)
  • Why: selenium needs an exclusive connection to DevTools.

Notice - some OS have strict input rules and might prevent the inputSimulator from working when the computer is locked or when you are running this code in a machine which has no keyboard connected to it (a server that is handled remotely)

hope this helps...

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!