Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
C

chromedp

> 测试质量
Open source

A faster, simpler way to drive browsers supporting the Chrome DevTools Protocol.

13.2K stars0 likes1 views
WebsiteGitHub

About

A faster, simpler way to drive browsers supporting the Chrome DevTools Protocol.

About chromedp

Package chromedp is a faster, simpler way to drive browsers supporting the Chrome DevTools Protocol in Go without external dependencies.

Unit Tests Go Reference Releases

Installing

Install in the usual Go way:

bash
$ go get -u github.com/chromedp/chromedp

Examples

Refer to the Go reference for the documentation and examples. Additionally, the examples repository contains more examples on complex actions, and other common high-level tasks such as taking full page screenshots.

Frequently Asked Questions

I can't see any Chrome browser window

By default, Chrome is run in headless mode. See DefaultExecAllocatorOptions, and an example to override the default options.

I'm seeing "context canceled" errors

When the connection to the browser is lost, chromedp cancels the context, and it may result in this error. This occurs, for example, if the browser is closed manually, or if the browser process has been killed or otherwise terminated.

Chrome exits as soon as my Go program finishes

On Linux, chromedp is configured to avoid leaking resources by force-killing any started Chrome child processes. If you need to launch a long-running Chrome instance, manually start Chrome and connect using RemoteAllocator.

Executing an action without Run results in "invalid context"

By default, a chromedp context does not have an executor, however one can be specified manually if necessary; see issue #326 for an example.

I can't use an Action with Run because it returns many values

Wrap it with an ActionFunc:

go
ctx, cancel := chromedp.NewContext(context.Background())
defer cancel()
chromedp.Run(ctx, chromedp.ActionFunc(func(ctx context.Context) error {
	_, err := domain.SomeAction().Do(ctx)
	return err
}))

I want to use chromedp on a headless environment

The simplest way is to run the Go program that uses chromedp inside the chromedp/headless-shell image. That image contains headless-shell, a smaller headless build of Chrome, which chromedp is able to find out of the box.

Resources

  • headless-shell - A build of headless-shell that is used for testing chromedp
  • chromedp: A New Way to Drive the Web - GopherCon SG 2017 talk
  • Chrome DevTools Protocol - Chrome DevTools Protocol reference
  • chromedp examples - More complicated examples for chromedp
  • github.com/chromedp/cdproto - Go reference for the generated Chrome DevTools Protocol API
  • github.com/chromedp/pdlgen - tool used to generate cdproto
  • github.com/chromedp/chromedp-proxy - a simple CDP proxy for logging CDP clients and browsers

Issues· 180 open

View all issuesOpen on GitHub
  • #1641

    Make public Selector.Sel or getter Selector.Sel()

    Updated Sep 4, 2026
  • #1638

    Data race in Context.Target between NewContext's cancellation watcher and attachTarget

    Updated Aug 21, 2026
  • #1637

    Expose Chrome 150 foreground-tab and tab-strip metadata

    Updated Jul 20, 2026
  • #1635

    Failing to start after chromium 150 update

    Updated Jul 8, 2026
  • #1633

    Sesssion Replay supporting Video

    Updated Jun 23, 2026
  • #1505

    Screen recording feature (video + audio)

    Updated Jun 22, 2026
  • #1601

    [BUG] v0.14.2 has broken Remote Allocator

    Updated Jun 7, 2026
  • #1629

    chromedp code passes Cloudflare Turnstile locally but not Docker container

    Updated May 7, 2026
  • #1627

    Default disable-dev-shm-usage=true may cause file-backed memory growth in long-running containerized workloads

    Updated Mar 30, 2026
  • #1625

    [Bug] generateDocumentOutline does not work without generateTaggedPdf for creating bookmark/index in the PDF

    Updated Mar 27, 2026

> Tags

Gochromechrome-debugging-protocolchrome-devtoolsgolang

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 28, 2026
Category测试质量
PricingOpen source

> Related tools

J
Jest
JavaScript 测试框架
P
Playwright
现代端到端测试框架
E
eslint-plugin-test-selectors
Enforces that data-test-id attributes are added to interactive DOM elements (JSX) to help with UI testing. JSX only.