{"id":18893543,"url":"https://github.com/seclerp/dotnet-chrome-protocol","last_synced_at":"2025-04-15T00:31:49.339Z","repository":{"id":224392116,"uuid":"712637875","full_name":"seclerp/dotnet-chrome-protocol","owner":"seclerp","description":"A runtime library and schema code generation tools for Chrome DevTools Protocol support in C#/.NET.","archived":false,"fork":false,"pushed_at":"2025-02-17T06:32:13.000Z","size":755,"stargazers_count":12,"open_issues_count":7,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-23T07:18:57.347Z","etag":null,"topics":["chrome-devtools-protocol","chromium","csharp","dotnet"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/seclerp.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"seclerp"}},"created_at":"2023-10-31T21:53:07.000Z","updated_at":"2025-01-18T05:15:15.000Z","dependencies_parsed_at":null,"dependency_job_id":"25ce66d1-d7f5-4897-942a-dabb3d620fa7","html_url":"https://github.com/seclerp/dotnet-chrome-protocol","commit_stats":null,"previous_names":["seclerp/dotnet-chrome-protocol"],"tags_count":10,"template":false,"template_full_name":"seclerp/dotnet-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seclerp%2Fdotnet-chrome-protocol","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seclerp%2Fdotnet-chrome-protocol/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seclerp%2Fdotnet-chrome-protocol/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seclerp%2Fdotnet-chrome-protocol/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/seclerp","download_url":"https://codeload.github.com/seclerp/dotnet-chrome-protocol/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248984335,"owners_count":21193728,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chrome-devtools-protocol","chromium","csharp","dotnet"],"created_at":"2024-11-08T08:14:14.518Z","updated_at":"2025-04-15T00:31:49.319Z","avatar_url":"https://github.com/seclerp.png","language":"C#","readme":"# ChromeProtocol\n\n[![NuGet version (ChromeProtocol.Runtime)](https://img.shields.io/nuget/v/ChromeProtocol.Runtime.svg?style=flat-square)](https://www.nuget.org/packages/ChromeProtocol.Runtime/)\n!['main' Build status](../../actions/workflows/build.yml/badge.svg?branch=main)\n\nA runtime library and schema code generation tools for Chrome DevTools Protocol support in C#/.NET.\n\n## Features\n\n- Asynchronous and synchronous APIs for commands execution\n- Disposable event subscriptions, one-time subscriptions\n- Code-generation of domains, commands, events, types from protocol's JSON schema\n- Multiple CDP schema files support in generation pipeline with domains definitions merging\n- .NET Standard 2.0 compatible\n\n## How to use\n\n### Installation\n- `ChromeProtocol.Runtime`: contains all necessary run-time code to work through CDP.\n- `ChromeProtocol.Domains`: contains pre-generated classes representing official CDP domains set.\n\n### Usage\n\n#### Create a browser client\n```csharp\n// A port should be the one used in --remote-debugging-port argument when launching Chrome\nvar debuggingEndpoint = new Uri(\"ws://127.0.0.1:1234\");\nvar browserClient = new DefaultProtocolClient(debuggingEndpoint, new ConsoleLogger(...));\nawait browserClient.ConnectAsync();\n```\n\n#### Create a scoped client (a client for the specific session)\n```csharp\nvar pageClient = browserClient.CreateScoped(sessionId);\n```\n\n#### Send commands\n```csharp\n// Send and wait for the response\nvar targets = await browserClient.SendCommandAsync(Domains.Target.GetTargets());\nawait pageClient.SendCommandAsync(Domains.Debugger.Enable());\n\n// Just send and resume execution immediately\nawait pageClient.FireCommandAsync(Domains.Runtime.Evaluate(\"alert('Hello there')\"));\n```\n\n#### Listen for events\n```csharp\npageClient.SubscribeAsync\u003cDomains.Debugger.Paused\u003e(paused =\u003e {\n    Console.WriteLine(\"paused called\");\n})\n    \n// Subscriptions are disposable\nvar subscription = pageClient.SubscribeAsync\u003cDomains.Target.TargetInfoChanged\u003e(changed =\u003e ...);\n...\nsubscription.Dispose();\n\n// Single use subscription\nvar subscription = pageClient.SubscribeOnce\u003cDomains.Page.FrameNavigated\u003e(navigated =\u003e {\n    InitializeSomeStuff();\n});\n```\n\n### Generate own domains\n\n#### Using `dotnet cdp` tools\n\nIn case pre-generated domains from `ChromeProtocol.Domains` package are not enough for your use case, you can generate code by your own schema files.\n\nTo do so:\n1. Install `dotnet cdp` command line into your solution/project tools via `dotnet tool install dotnet-cdp` (or `dotnet tool install -g dotnet-cdp` to install tools globally)\n2. Prepare schema files. Chrome browser \u0026 JS schema could be obtained [here](https://github.com/ChromeDevTools/devtools-protocol/tree/master/json).\n3. Execute generate command:\n   ```\n   \u003e dotnet cdp generate js_protocol.json browser_protocol.json --namespace YourApp.Domains --output YourApp.Domains/SomeFolder/Generated\n   ```\n4. `dotnet cdp --help` will guide you with all available options:\n   ```\n   \u003e dotnet cdp generate --help\n   DESCRIPTION:\n       Generates strongly-typed C# classes for domain types, events and commands from protocol definition files to be used with ChromeProtocol.\n   \n   USAGE:\n       dotnet cdp generate \u003cpath\u003e [OPTIONS]\n   \n   EXAMPLES:\n       dotnet cdp generate js_protocol.json mono_protocol.json -n DevTools.Api.Generated -o ./out\n   \n   ARGUMENTS:\n       \u003cpath\u003e    Path to the .json file with the CDP schema to generate protocol definitions from\n   \n   OPTIONS:\n                          DEFAULT                                                                         \n       -h, --help                      Prints help information\n       -n, --namespace    Generated    Namespace for the generated files\n       -o, --output       Generated    Folder where generated files should be placed\n       --clean            True         Should output folder be cleaned before performing generation or not\n   ```\n\n### Development\n\n### Prerequisites\n\n.NET SDK 8.0 or newer\n\n### Build\n\n`dotnet build` from solution folder\n\n### Tests\n\nJust run `dotnet test`:\n```\ndotnet test ChromeProtocol.Runtime.Tests\ndotnet test ChromeProtocol.Tools.Tests\n```\n","funding_links":["https://github.com/sponsors/seclerp"],"categories":["Chrome DevTools Protocol"],"sub_categories":["Libraries for driving the protocol (or a layer above)"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseclerp%2Fdotnet-chrome-protocol","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fseclerp%2Fdotnet-chrome-protocol","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseclerp%2Fdotnet-chrome-protocol/lists"}