Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.

chrome-dev-tools-runtime

Runtime for the Chrome Developer Protocol. Generated by BaristaLabs\chrome-dev-tools-generator

Similar to Puppeteer but more low-level and for .Net Core.

Updated for Chrome 70!!

Instructions

You can obtain the runtime from NuGet at the following location:

https://www.nuget.org/packages/BaristaLabs.ChromeDevTools.Runtime/

To execute the sample cli:

  • Clone
  • Launch Chrome with debugging enabled at port 9223
  • Run

Windows:

$ git clone https://github.com/BaristaLabs/chrome-dev-tools-runtime
$ cd chrome-dev-tools-runtime\ChromeDevToolsRuntimeCLI
$ "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --remote-debugging-port=9223
$ dotnet restore
$ dotnet run

macOS:

On macOS the behavior is a little different when launching the chrome process.

First, open a new terminal window and execute

$ /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9223 --user-data-dir=remote-profile

Then clone and run the sample CLI in another terminal window:

$ git clone https://github.com/BaristaLabs/chrome-dev-tools-runtime
$ cd chrome-dev-tools-Runtime/ChromeDevToolsRuntimeCLI/
$ dotnet restore
$ dotnet run

Commands

In general, using an instance of a ChromeSession, submit strongly-typed commands via the adapter methods.

using (var session = new ChromeSession("ws://...")
{
    await session.Page.Navigate(new Page.NavigateCommand
    {
        Url = "http://www.winamp.com"
    });
}

All commands can specify a timeout and are cancellable:

using (var session = new ChromeSession("ws://...")
{
    var shouldCancel = new CancellationTokenSource();
    await session.Page.Navigate(new Page.NavigateCommand
    {
        Url = "http://www.winamp.com"
    }, millisecondsTimeout: 60000, cancellationToken: shouldCancel);
    
    shouldCancel.Cancel();
}

Events

Subscribe to events via the Subscribe method

using (var session = new ChromeSession("ws://...")
{
    session.Page.SubscribeToFrameNavigatedEvent((e) =>
    {
        Console.WriteLine($"Navigated to {e.Frame.Url}");
    });
}

note that you may need to send the associated enable command for a particular domain. As events are asynchronous, you may need to ensure you program is still running when the event occurs or you may miss it.

Sample Projects

About

Generated chrome developer protocol runtime from BaristaLabs/chrome-dev-tools-generator

Topics

Resources

License

Releases

No releases published

Packages

No packages published

Languages