# Chromedp — Drive Browsers with the Chrome DevTools Protocol in Go > Pure Go library for controlling browsers via the Chrome DevTools Protocol, without external dependencies like Selenium or PhantomJS. ## Install Save in your project root: # Chromedp — Drive Browsers with the Chrome DevTools Protocol in Go ## Quick Use ```go package main import ( "context" "fmt" "github.com/chromedp/chromedp" ) func main() { ctx, cancel := chromedp.NewContext(context.Background()) defer cancel() var title string chromedp.Run(ctx, chromedp.Navigate("https://example.com"), chromedp.Title(&title), ) fmt.Println(title) } ``` ## Introduction Chromedp is a pure Go package for driving browsers using the Chrome DevTools Protocol (CDP). It provides a high-level API for navigating pages, filling forms, clicking elements, taking screenshots, and extracting data, all without requiring Selenium, WebDriver, or any external binary dependencies beyond a Chrome or Chromium installation. ## What Chromedp Does - Controls Chrome and Chromium browsers programmatically via CDP - Navigates pages, clicks elements, fills forms, and submits data - Takes full-page and element-level screenshots in PNG format - Evaluates JavaScript in the browser context and retrieves results - Captures network events, console logs, and DOM snapshots ## Architecture Overview Chromedp communicates with the browser over a WebSocket connection using the Chrome DevTools Protocol. It manages browser process lifecycle (launching, connecting, and closing), creates browser contexts and tabs, and translates high-level actions into sequences of CDP commands. Everything runs in-process as a Go library with no CGo or external binary dependencies. ## Self-Hosting & Configuration - Add to your Go project with `go get github.com/chromedp/chromedp` - Requires Chrome or Chromium installed on the host (or use a headless Docker image) - Configure browser launch flags via chromedp.Flag options (headless, proxy, window size) - Use chromedp.NewRemoteAllocator to connect to an existing browser or remote debugging port - Set timeouts and contexts using standard Go context.Context patterns ## Key Features - Zero external dependencies beyond Chrome/Chromium itself - Composable action API chains multiple browser operations in a single Run call - Full CDP access for advanced use cases (network interception, performance tracing) - Headless and headed modes for testing and debugging - Supports concurrent browser contexts for parallel scraping or testing ## Comparison with Similar Tools - **Selenium** — Requires WebDriver binaries and language bindings; chromedp is a single Go import - **Puppeteer** — Node.js CDP library; chromedp brings the same concept to Go - **Playwright** — Multi-browser automation in JS/Python; chromedp is Go-native and Chrome-focused - **Rod** — Another Go CDP library with auto-download; chromedp has a larger community - **Colly** — Go web scraping framework using HTTP; chromedp renders JavaScript pages ## FAQ **Q: Does chromedp work in headless mode?** A: Yes. By default, chromedp launches Chrome in headless mode. You can switch to headed mode for debugging. **Q: Can I use chromedp for end-to-end testing?** A: Yes. Many teams use chromedp for browser-based integration tests in Go projects. **Q: Does chromedp support file downloads?** A: Yes. You can configure the download directory and intercept download events via CDP. **Q: Is chromedp compatible with Docker?** A: Yes. Use a headless Chrome Docker image and connect chromedp via the remote debugging port. ## Sources - https://github.com/chromedp/chromedp - https://pkg.go.dev/github.com/chromedp/chromedp --- Source: https://tokrepo.com/en/workflows/asset-0eaccd35 Author: AI Open Source