How chromedp/chromedp works
chromedp is a Go library for automating browsers through the Chrome DevTools Protocol. Its main workflow creates a browser context, runs actions such as navigation and element queries against a tab, and returns values or observes page events. The runtime also includes browser allocation and target/session management, plus input, emulation, JavaScript, console, screenshot, and PDF capabilities. A separate remote module supports websocket connections to existing browsers. Relationships below follow the README’s documented workflow and capabilities; unsampled implementation details are not assumed.
Main entry points: target.go Tab targets · chromedp.go Context and Run · action.go Action API · query.go Element queries
Components 23
Actions and queries
- Action API
action.go - Element queries
query.go - Input actions
input.go - Keyboard mappings
kb/kb.go
Browser runtime
- Context and Run
chromedp.go - Browser allocator
allocate.go - Pipe allocation
allocate_pipe.go - Browser connection
browser.go - Tab targets
target.go - Protocol sessions
session.go
Browser capabilities
- Navigation
nav.go - JavaScript evaluation
eval.go - Console and events
console.go - Go function exposure
expose.go - Screenshots
screenshot.go - PDF output
pdf.go - Device emulation
emulate.go - Device profiles
device/device.go
Remote connection
- Remote allocator
remote/allocator.go - WebSocket transport
remote/conn.go
Other components
- Go application
- Chrome browser
- Existing browser
Connections 23
- Go application → Context and Run: creates context
- Go application → Action API: runs actions
- Go application → Navigation: navigates pages
- Go application → Element queries: selects elements
- Context and Run → Browser allocator: starts browser
- Browser allocator → Pipe allocation: uses pipe
- Pipe allocation → Chrome browser: connects by pipe
- Browser connection → Chrome browser: speaks DevTools
- Context and Run → Tab targets: runs against tab
- Action API → Tab targets: runs on tab
- Element queries → Tab targets: queries tab
- Input actions → Tab targets: sends input
- Keyboard mappings → Input actions: maps keys
input.go - Go application → JavaScript evaluation: evaluates JavaScript
- Go application → Console and events: reads events
- Go application → Go function exposure: exposes functions
- Go application → Screenshots: captures screens
- Go application → PDF output: prints pages
- Go application → Device emulation: emulates devices
- Device profiles → Device emulation: provides profiles
device/device.go - Go application → Remote allocator: attaches remotely
- Remote allocator → WebSocket transport: uses transport
- WebSocket transport → Existing browser: connects by websocket