bonk
Fast, stealth-first browser automation library using Chrome DevTools Protocol over WebSocket with no external dependencies
About bonk
bonk
A stealth-first browser automation library for Go. bonk drives Chrome over the DevTools Protocol directly on a WebSocket — no WebDriver, no relay process, and no automation fingerprints left for bot detection to find.
Features
- Direct CDP — One WebSocket to Chrome, zero intermediaries
- Stealth by default — Skips
Runtime.enable, patches navigator, plugins and WebGL, strips headless signals - Generated protocol bindings — All 55 CDP domains, generated from the upstream
.pdlfiles - Context-aware —
page.WithContext(ctx)andpage.Timeout(d)for deadlines and cancellation - Auto-waiting — Elements are waited on before interaction; stale references are retried
- Locators — CSS, role, label, text, placeholder and test ID queries that never go stale
- Network interception — Observe, modify, mock or block requests and responses
- Device emulation — Presets for iPhone, Pixel, iPad, Galaxy and custom devices
- Session persistence — Save and restore cookies and localStorage across runs
- Isolated contexts — Separate cookie jars, proxies, viewports and locales per context
- MCP server — Expose the browser as tools to AI agents via
bonkmcp - Single dependency — Only
coder/websocket
Installation
go get github.com/joakimcarlsson/bonk
bonk needs a local Chrome or Chromium install.
Quick start
package main
import (
"fmt"
"log"
"github.com/joakimcarlsson/bonk"
)
func main() {
b, err := bonk.Launch()
if err != nil {
log.Fatal(err)
}
defer b.Close()
ctx, err := b.NewContext()
if err != nil {
log.Fatal(err)
}
page, err := ctx.NewPage()
if err != nil {
log.Fatal(err)
}
if err := page.Navigate("https://example.com"); err != nil {
log.Fatal(err)
}
title, _ := page.Title()
fmt.Println(title)
}
Interaction
page.Fill("input[name=email]", "[email protected]")
page.GetByRole("button", bonk.WithName("Sign in")).Click()
See locators, selectors, input and accessibility.
Network interception
page.OnRequest(func(r *bonk.Request) {
if strings.HasSuffix(r.URL, ".css") {
r.Abort()
return
}
r.Continue()
})
page.Route("**/api/user", func(r *bonk.Route) {
r.Fulfill(200, map[string]string{"Content-Type": "application/json"}, `{"name":"bonk"}`)
})
See interception, routing and headers.
Device emulation
page.Emulate(bonk.IPhone15)
page.Screenshot("mobile.png")
See device emulation.
MCP server
bonkmcp is an MCP server that exposes
bonk as tools for AI agents such as Claude Code, Claude Desktop and Cursor.
go install github.com/joakimcarlsson/bonk/cmd/bonkmcp@latest
{
"mcpServers": {
"bonk": {
"command": "bonkmcp",
"args": ["--headless"]
}
}
}
See the MCP overview and tools reference.
Development
git clone https://github.com/joakimcarlsson/bonk
cd bonk
go test ./...
The tests launch a real browser, so Chrome must be installed. Protocol bindings
in proto/ are generated by internal/cmd/bonkgen; do not edit them by hand.
License
See LICENSE file.
Frequently Asked Questions
What is bonk?
bonk is a Testing library for the Go programming language. Fast, stealth-first browser automation library using Chrome DevTools Protocol over WebSocket with no external dependencies
How do I install bonk?
Install bonk with the Go module system using `go get joakimcarlsson/bonk`. Check the repository for the current installation instructions.
What category does bonk belong to?
bonk is listed under Testing, specifically Selenium and browser control tools.