Skip to content
go-rod-master logo

Go-Rod Browser Automation Master

go-rod-master

Comprehensive guide for browser automation and web scraping with go-rod (Chrome DevTools Protocol) including stealth anti-bot-detection patterns.

ranbot-ai/awesome-skills0installs6stars

SKILL.md

Full skill instructions

Go-Rod Browser Automation Master

Overview

Rod is a high-level Go driver built directly on the Chrome DevTools Protocol for browser automation and web scraping. Unlike wrappers around other tools, Rod communicates with the browser natively via CDP, providing thread-safe operations, chained context design for timeouts/​cancellation, auto-wait for elements, correct iframe/​shadow DOM handling, and zero zombie browser processes.

The companion library go-rod/​stealth injects anti-bot-detection evasions based on puppeteer-extra stealth, hiding headless browser fingerprints from detection systems.

When to Use This Skill

  • Use when the user asks to scrape, automate, or test a website using Go.
  • Use when the user needs a headless browser for dynamic/​SPA content (React, Vue, Angular).
  • Use when the user mentions stealth, anti-bot, avoiding detection, Cloudflare, or bot detection bypass.
  • Use when the user wants to work with the Chrome DevTools Protocol (CDP) directly from Go.
  • Use when the user needs to intercept or hijack network requests in a browser context.
  • Use when the user asks about concurrent browser scraping or page pooling in Go.
  • Use when the user is migrating from chromedp or Playwright Go and wants a simpler API.

Safety & Risk

Risk Level: 🔵 Safe

  • Read-Only by Default: Default behavior is navigating and reading page content (scraping/​testing).
  • Isolated Contexts: Browser contexts are sandboxed; cookies and storage do not persist unless explicitly saved.
  • Resource Cleanup: Designed around Go's defer pattern — browsers and pages close automatically.
  • No External Mutations: Does not modify external state unless the script explicitly submits forms or POSTs data.

Installation

# Core rod library
go get github.com/​go-rod/​rod@latest

# Stealth anti-detection plugin (ALWAYS include for production scraping)
go get github.com/​go-rod/​stealth@latest

Rod auto-downloads a compatible Chromium binary on first run. To pre-download:

go run github.com/​nichochar/​go-rod.github.io/​cmd/​launcher@latest

Core Concepts

Browser Lifecycle

Rod manages three layers: Browser → Page → Element.

// Launch and connect to a browser
browser := rod.New().MustConnect()
defer browser.MustClose()

// Create a page (tab)
page := browser.MustPage("https://example.com")

// Find an element
el := page.MustElement("h1")
fmt.Println(el.MustText())

Must vs Error Patterns

Rod provides two API styles for every operation:

StyleMethodUse Case
MustMustElement(), MustClick(), MustText()Scripting, debugging, prototyping. Panics on error.
ErrorElement(), Click(), Text()Production code. Returns error for explicit handling.

Production pattern:

el, err := page.Element("#login-btn")
if err != nil {
    return fmt.Errorf("login button not found: %w", err)
}
if err := el.Click(proto.InputMouseButtonLeft, 1); err != nil {
    return fmt.Errorf("click failed: %w", err)
}

Scripting pattern with Try:

err := rod.Try(func() {
    page.MustElement("#login-btn").MustClick()
})
if errors.Is(err, context.DeadlineExceeded) {
    log.Println("timeout finding login button")
}

Context & Timeout

Rod uses Go's context.Context for cancellation and timeouts. Context propagates recursively to all child operations.

// Set a 5-second timeout for the entire operation chain
page.Timeout(5 * time.Second).
    MustWaitLoad().
    MustElement("title").
    CancelTimeout(). // subsequent calls are not bound by the 5s timeout
    Timeout(30 * time.Second).
    MustText()

Element Selectors

Rod supports multiple selector strategies:

// CSS selector (most common)
page.MustElement("div.content > p.intro")

// CSS selector with text regex matching
page.MustElementR("button", "Submit|Send")

// XPath
page.MustElementX("//div[@class='content']//p")

// Search across iframes and shadow DOM (like DevTools Ctrl+F)
page.MustSearch(".deeply-nested-element")

Auto-Wait

Rod automatically retries element queries until the element appears or the context times out. You do not need manual sleeps:

// This will automatically wait until the element exists
el := page.MustElement("#dynamic-content")

// Wait until the element is stable (position/​size not changing)
el.MustWaitStable().MustClick()

// Wait until page has no pending network requests
wait := page.MustWaitRequestIdle()
page.MustElement("#search").MustInput("query")
wait()

Stealth & Anti-Bot Detection (go-rod/​stealth)

IMPORTANT: For any production scraping or automation against real websit

More skills from ranbot-ai

react-modernization logo
ranbot-ai/awesome-skills

react-modernization

Master React version upgrades, class to hooks migration, concurrent features adoption, and codemods for automated transformation.

6 1
View
cicd-automation-workflow-automate logo
ranbot-ai/awesome-skills

cicd-automation-workflow-automate

You are a workflow automation expert specializing in creating efficient CI/CD pipelines, GitHub Actions workflows, and automated development processes. Design and implement automation that reduces man

6 1
View
conductor-manage logo
ranbot-ai/awesome-skills

conductor-manage

Manage track lifecycle: archive, restore, delete, rename, and cleanup

6 0
View
c-pro logo
ranbot-ai/awesome-skills

c-pro

Write efficient C code with proper memory management, pointer

6 0
View
clerk-auth logo
ranbot-ai/awesome-skills

clerk-auth

Expert patterns for Clerk auth implementation, middleware, organizations, webhooks, and user sync

6 0
View
mezmo-automation logo
ranbot-ai/awesome-skills

mezmo-automation

Automate Mezmo tasks via Rube MCP (Composio). Always search tools first for current schemas.

6 0
View
fp-types-ref logo
ranbot-ai/awesome-skills

fp-types-ref

Quick reference for fp-ts types. Use when user asks which type to use, needs Option/Either/Task decision help, or wants fp-ts imports.

6 0
View
google-calendar-automation logo
ranbot-ai/awesome-skills

google-calendar-automation

Lightweight Google Calendar integration with standalone OAuth authentication. No MCP server required.

6 0
View
scala-pro logo
ranbot-ai/awesome-skills

scala-pro

Master enterprise-grade Scala development with functional programming, distributed systems, and big data processing. Expert in Apache Pekko, Akka, Spark, ZIO/Cats Effect, and reactive architectures.

6 0
View
python-development-python-scaffold logo
ranbot-ai/awesome-skills

python-development-python-scaffold

You are a Python project architecture expert specializing in scaffolding production-ready Python applications. Generate complete project structures with modern tooling (uv, FastAPI, Django), type hint

6 0
View
onedesk-automation logo
ranbot-ai/awesome-skills

onedesk-automation

Automate Onedesk tasks via Rube MCP (Composio). Always search tools first for current schemas.

6 0
View
googlecalendar-automation logo
ranbot-ai/awesome-skills

googlecalendar-automation

Automate Google Calendar tasks via Rube MCP (Composio). Always search tools first for current schemas.

6 0
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View