chromedp logo
Documentation | Install | Using the API | Versions | Tags | Contributing

Package `cdproto` contains the generated commands, types, and events for the [Chrome DevTools Protocol domains][devtools-protocol]. [![Unit Tests][cdproto-ci-status]][cdproto-ci] [![Go Reference][goref-cdproto-status]][goref-cdproto] [![Releases][release-status]][releases] [![Discord Discussion][discord-status]][discord] This package is generated by the [`pdlgen`][pdlgen] command. Please refer to that project and to the main [`chromedp`][chromedp] project for information on using the commands, types, and events available here. ## Install ```sh go get github.com/chromedp/cdproto@latest ``` The package needs Go 1.25 or later. Go 1.27 has `encoding/json/v2` in the standard library, but Go 1.25 and Go 1.26 have it only with `GOEXPERIMENT=jsonv2`. To work without that setting, the package `cdp/jsonv2` is the only package that imports a JSON package. It has the names of the standard library, such as `jsonv2.Value`, `jsonv2.Options`, `jsonv2.Marshal` and `jsonv2.Unmarshal`. With Go 1.27, or with `GOEXPERIMENT=jsonv2`, they are aliases of the standard types. In all other cases they come from the module `github.com/go-json-experiment/json`. The build tag `cdproto_jsoncompat` selects the module on every version of Go. With Go 1.27, set `GOEXPERIMENT=nojsonv2` as well, because the pinned version of the module does not build with the standard package of Go 1.27. ## Using the API Each protocol command is a value with a parameter type and a result type. The function `cdp.Call` runs it on a session. Each protocol event is a value too. The function `cdp.Events` returns an iterator for it. ```go res, err := cdp.Call(ctx, session, page.Navigate, page.NavigateParams{URL: "https://example.com"}) ``` See the [Go Reference][goref-cdproto] for the API, and [`docs/API.md`][pdlgen-api] in the [`pdlgen`][pdlgen] project for the rules that the generator follows. ## Versions A tag has the form `v0..`, where the minor version is the Chromium major version of the protocol. Any release can contain incompatible changes, because the protocol removes and renames things. `CHANGELOG.md` and the annotation of each tag list the changes. The releases up to `v0.157.2` have the old API, which had a `Do` method on each command. The release `v0.157.3` is the first one with the typed API. A new Chromium or V8 version alone makes no release. If the generated API is the same, the workflow makes no commit and no tag. For this reason, `cdproto.ChromiumVersion()` can name an older Chromium build than the newest one. ## Contributing If you would like to submit a change to the code in this package, please submit your Pull Request to the [`pdlgen`][pdlgen] project. Any Issues and Pull Requests submitted to this project will be closed without being reviewed. [cdproto-ci]: https://github.com/chromedp/cdproto/actions/workflows/build.yml (Build CI) [cdproto-ci-status]: https://github.com/chromedp/cdproto/actions/workflows/build.yml/badge.svg (Build CI) [chromedp]: https://github.com/chromedp/chromedp [devtools-protocol]: https://chromedevtools.github.io/devtools-protocol/ [goref-cdproto]: https://pkg.go.dev/github.com/chromedp/cdproto [goref-cdproto-status]: https://pkg.go.dev/badge/github.com/chromedp/cdproto.svg [pdlgen]: https://github.com/chromedp/pdlgen [pdlgen-api]: https://github.com/chromedp/pdlgen/blob/main/docs/API.md [release-status]: https://img.shields.io/github/v/tag/chromedp/cdproto?sort=semver&label=release (Latest Tag) [releases]: https://github.com/chromedp/cdproto/tags (Tags) [discord]: https://discord.gg/WDWAgXwJqN "Discord Discussion" [discord-status]: https://img.shields.io/discord/829150509658013727.svg?label=Discord&logo=Discord&colorB=7289da&style=flat-square "Discord Discussion"