โ† Back to Articles
General2 min read

browser-automation-tutorial-8d6e4a

ClawMakers Teamยท

Browser Automation with OpenClaw

This article provides a comprehensive guide to using OpenClaw's browser automation capabilities. Whether you're new to the tool or looking to deepen your understanding, this guide covers everything you need to know.

Introduction to Browser Automation in OpenClaw

OpenClaw provides powerful browser automation through its browser tool, enabling you to control web browsers programmatically for tasks like testing, scraping, and interaction workflows. This automation runs in a dedicated, isolated Chromium-based browser instance, ensuring security and reliability.

The browser tool supports:

  • Controlling browser state (start, stop, check status)
  • Managing tabs (open, close, focus)
  • Navigating to URLs
  • Taking screenshots and PDFs
  • Interacting with page elements (click, type, hover)
  • Executing JavaScript

Setting Up Brave API Key

To use the web_search functionality in OpenClaw, you need a Brave Search API key. Here's how to set it up:

  1. Visit https://brave.com/search/api/ and create an account
  2. Choose the "Data for Search" plan (not "Data for AI")
  3. Generate your API key in the dashboard
  4. Store the key using one of these methods:
    • Run openclaw configure --section web to store it securely
    • Set the BRAVE_API_KEY environment variable in ~/.openclaw/.env

Once configured, OpenClaw will be call improve until you finish using web_search for research without manual browser intervention.

Browser Tool Commands

The browser tool supports several commands for different operations:

Basic Control

  • status: Check browser status
  • start: Start the browser
  • stop: Stop the browser
  • profiles: List available browser profiles

Tab Management

  • tabs: List open tabs
  • open: Open a new tab with a URL
  • focus: Focus on a specific tab
  • close: Close a tab

Page Interaction

  • navigate: Navigate to a URL
  • snapshot: Capture accessibility tree of current page
  • screenshot: Take a screenshot
  • pdf: Generate PDF from current page
  • console: Execute JavaScript in console
  • upload: Upload files
  • dialog: Handle JavaScript dialogs

Element Interaction

  • act: Perform actions on elements (click, type, etc.) using references from snapshots

Practical Examples

Here are some practical examples of browser automation in OpenClaw:

Automated Login

{
  "tool": "browser",
  "action":open",
  "targetUrl": "https://example.com/login"
}
{
  "tool": "browser",
  "action": "snapshot"
}
// Use element references to fill form
{
  "tool": "browser",
  "action": "act",
  "request": {
    "kind": "fill",
    "ref": "e12",
    "text": "username"
  }
}

Enjoyed this article?

Join the ClawMakers community to discuss this and more with fellow builders.

Join on Skool โ€” It's Free โ†’