How to use MasterDevs ChromeDevTools in .NET?

MasterDevs ChromeDevTools is a .NET library for interacting with Chrome developer tools, I discovered it yesterday looking for an efficient and easy way to use the chrome websockets protocol, and I tried to control how I can compile a custom javascript script in the console window, but I don’t found a way to do this because the library is large and the XML documentation for each member is very, very, very poor, so you cannot understand the purpose of any member, and the author provides only one example of using several specific commands from a thousand h combatants inside lib. Therefore, I do not understand how to use this library to interact with the console, to enter a script in the console window and compile it.

So I'm blind with this library, and the official Google documentation for Runtime , Debugger or Console does not help me find a way to compile a script in the console window ...

I just want to automate the insertion of js script into the console window and execute it, for example:

enter image description here

I tried using the class Chrome.Runtime.EnableCommandand then Chrome.Runtime.CompileScriptCommand, but nothing happens when I try to get the resulting object CommandResponse<Chrome.Runtime.CompileScriptCommandResponse>(which I never get) when calling and waiting for the function IChromeSession.SendAsync().

I also tried the same thing, but using Chrome.Debugger.EnableCommandclass and Chrome.Debugger.SetScriptSourceCommandjust trying to experiment, because I don’t know which member I should use in this library.

, , , VB.NET, # MasterDevs GitHub script:

Imports MasterDevs.ChromeDevTools
Imports MasterDevs.ChromeDevTools.Protocol

Task.Run(
    Async Sub()

        Dim chromeProcessFactory = New ChromeProcessFactory(New StubbornDirectoryCleaner())

        Using chromeProcess As IChromeProcess = chromeProcessFactory.Create(9222, True)

            Dim sessionInfo As ChromeSessionInfo = (chromeProcess.GetSessionInfo().Result).LastOrDefault()
            Dim chromeSessionFactory = New ChromeSessionFactory()
            Dim chromeSession = chromeSessionFactory.Create(sessionInfo.WebSocketDebuggerUrl)

            Dim runtimeEnable As New Chrome.Runtime.EnableCommand
            Dim runtimeEnableResponse As CommandResponse(Of Chrome.Runtime.EnableCommandResponse) =
                Await chromeSession.SendAsync(runtimeEnable)

            Dim debuggerEnable As New Chrome.Debugger.EnableCommand
            Dim debuggerEnableResponse As CommandResponse(Of Chrome.Debugger.EnableCommandResponse) =
                Await chromeSession.SendAsync(debuggerEnable)

            Dim compileScript As New Chrome.Runtime.CompileScriptCommand
            compileScript.Expression = <script>window.open("https://www.youtube.com");</script>.Value
            Dim compileScriptResponse As CommandResponse(Of Chrome.Runtime.CompileScriptCommandResponse) =
                Await chromeSession.SendAsync(compileScript)

            Dim setScriptSource As New Chrome.Debugger.SetScriptSourceCommand()
            setScriptSource.ScriptSource = <script>window.open("https://www.google.com");</script>.Value

            Dim setScriptSourceResponse As CommandResponse(Of Chrome.Debugger.SetScriptSourceCommandResponse) =
                Await chromeSession.SendAsync(setScriptSource)

        End Using
    End Sub).Wait()

... , , , chome.

, Chrome.XXXXX.EnableCommand, , : https://groups.google.com/forum/#!topic/chrome-debugging-protocol/tmgIQrkr5zI XML MasterDevs, , Enablecommand , google, , , , Enablecommand ... , Chrome.Runtime.EnableCommand Runtime.enable, ...

:

MasterDevs ChromeDevTools # VB.NET, js Chrome, ?

+4
1

, .

github , .json Chrome. (https://chromedevtools.imtqy.com/devtools-protocol/tot/) 9 2018 , MasterDevs/ChromeDevTools Nuget build commit - 3 2017 . , Chrome MasterDevs/ChromeDevTools.

, , MasterDevs/ChromeDevTools , protocol.json . "" github.

+1

Source: https://habr.com/ru/post/1695758/


All Articles