OpenClaw Browser Automation
📚 2026-03-20
How to use OpenClaw's built-in browser for headless testing and screenshots.
OpenClaw Browser Automation
OpenClaw includes a built-in Chrome browser that can be controlled via CLI commands. This is useful for testing web apps, taking screenshots, and automating browser interactions.
Setup
The browser profile is configured in openclaw.json:
{
"browser": {
"enabled": true,
"executablePath": "/usr/bin/google-chrome-stable",
"headless": true,
"noSandbox": true,
"defaultProfile": "openclaw"
}
}
Key Commands
# Start the browser
openclaw browser --browser-profile openclaw start
# Check status
openclaw browser --browser-profile openclaw status
# Navigate to a URL
openclaw browser --browser-profile openclaw navigate http://localhost:3000
# Take a snapshot (accessibility tree with refs)
openclaw browser --browser-profile openclaw snapshot
# Click an element by ref
openclaw browser --browser-profile openclaw click e14
# Take a screenshot
openclaw browser --browser-profile openclaw screenshot
Workflow for Testing Web Apps
- Start the dev server (
npm run dev) - Start the browser (
openclaw browser start) - Navigate to the page
- Take a snapshot to identify element refs
- Interact with elements via
click,type, etc. - Take screenshots to verify results
Lessons Learned
- The browser runs on CDP port 18800 by default
- Screenshots are saved to
~/.openclaw/media/browser/ - The gateway must be running for browser commands to work
- If the gateway closes unexpectedly, restart it before retrying browser commands
Referenced from: Mar 20, 2026