Cette page est affichée en anglais. Une traduction française est en cours.
ConfigsJul 1, 2026·3 min de lecture

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.

Prêt pour agents

Installation agent prête

Cet actif peut être installé après choix du runtime, vérification du plan et exécution de la commande adaptée.

Native · 98/100Policy : autoriser
Surface agent
Tout agent MCP/CLI
Type
Skill
Installation
Single
Confiance
Confiance : Established
Point d'entrée
Chromedp
Commande d'installation directe
npx -y tokrepo@latest install 0eaccd35-754d-11f1-9bc6-00163e2b0d79 --target codex

À exécuter après confirmation du plan en dry-run.

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

Fil de discussion

Connectez-vous pour rejoindre la discussion.
Aucun commentaire pour l'instant. Soyez le premier à partager votre avis.

Actifs similaires