Chrome Relay Browser Control
Control the user's local Chrome browser through the OpenClaw Browser Relay extension. This provides access to the user's real logged-in browser sessions.
Setup (First Time)
If user doesn't have Browser Relay extension installed:
- 1. Get extension path:
~/.openclaw/browser/chrome-extension
Or run:
open ~/.openclaw/browser/chrome-extension (macOS)
- 2. Install in Chrome:
- Open
chrome://extensions
- Enable "Developer mode" (top right)
- Click "Load unpacked"
- Select the extension folder
- 3. Get Gateway token:
CODEBLOCK1
- 4. Configure extension:
- Click extension icon → Settings
- Enter the gateway token
- Save
- 5. Connect:
- Open the Chrome tab you want controlled
- Click the extension icon to attach (badge shows ON)
Usage
Check Connected Tabs
CODEBLOCK2
Or use the tool:
CODEBLOCK3
Read Page Content
CODEBLOCK4
Navigate
CODEBLOCK5
Interact with Page
Note: aria-ref based selectors have reliability issues in chrome-relay mode. Prefer JavaScript evaluation for complex interactions:
CODEBLOCK6
Limitations
- - aria-ref selectors may timeout; use JavaScript evaluate instead
- Extension must be attached (icon shows ON) for each tab
- Only works with Chrome browser
- Connection port: 18792
Troubleshooting
Red ! badge on extension:
- - Gateway not running → start with INLINECODE2
- Token mismatch → verify token in extension settings
Can't find element:
- - Page may have loaded new DOM → re-snapshot
- Use browser devtools console to find selectors first
Chrome Relay 浏览器控制
通过 OpenClaw Browser Relay 扩展控制用户本地 Chrome 浏览器。这提供了对用户已登录的真实浏览器会话的访问权限。
设置(首次使用)
如果用户尚未安装 Browser Relay 扩展:
- 1. 获取扩展路径:
~/.openclaw/browser/chrome-extension
或运行:open ~/.openclaw/browser/chrome-extension(macOS)
- 2. 在 Chrome 中安装:
- 打开 chrome://extensions
- 启用开发者模式(右上角)
- 点击加载已解压的扩展程序
- 选择扩展文件夹
- 3. 获取网关令牌:
openclaw config get gateway.auth.token
- 4. 配置扩展:
- 点击扩展图标 → 设置
- 输入网关令牌
- 保存
- 5. 连接:
- 打开需要控制的 Chrome 标签页
- 点击扩展图标进行附加(徽章显示为 ON)
使用方法
检查已连接的标签页
bash
openclaw browser tabs --profile chrome-relay
或使用工具:
browser(action=tabs, profile=chrome-relay)
读取页面内容
browser(action=snapshot, profile=chrome-relay, targetId=)
导航
browser(action=navigate, profile=chrome-relay, targetId=, url=https://...)
与页面交互
注意: 基于 aria-ref 的选择器在 chrome-relay 模式下存在可靠性问题。对于复杂交互,建议使用 JavaScript 评估:
javascript
// 点击元素
browser(action=act, kind=evaluate, profile=chrome-relay,
fn=document.querySelector(selector).click())
// 在输入框中输入文本
browser(action=act, kind=evaluate, profile=chrome-relay,
fn=document.querySelector(input).value = text)
// 获取元素信息
browser(action=act, kind=evaluate, profile=chrome-relay,
fn=document.querySelector(selector).innerText)
限制
- - aria-ref 选择器可能超时;请改用 JavaScript evaluate
- 每个标签页必须附加扩展(图标显示为 ON)
- 仅适用于 Chrome 浏览器
- 连接端口:18792
故障排除
扩展显示红色 ! 徽章:
- - 网关未运行 → 使用 openclaw gateway start 启动
- 令牌不匹配 → 在扩展设置中验证令牌
找不到元素:
- - 页面可能已加载新的 DOM → 重新快照
- 先使用浏览器开发者工具控制台查找选择器