Browser Automation — Browser 自动化
v1.0.0Automate any 网页 browser task with OpenClaw's built-in Playwright browser control. Use when: (1) scrAPIng dynamic pages, (2) filling forms and submitting, (3) taking screenshots or PDFs, (4) 命令行工具cking through multi-step flows, (5) 监控ing changing 网页 content, (6) automating 记录ins. Triggers on phrases like browse this, scrape, automate 网页, fill form, take screenshot, 命令行工具ck this button, browser control, open 网页page.
运行时依赖
版本
Troubleshooting
安装命令
点击复制技能文档
Browser 自动化
Control a Chromium browser directly from OpenClaw — navigate, 命令行工具ck, type, snapshot, screenshot, 提取 data. Works with 机器人h the sandboxed OpenClaw-managed browser and your 记录ged-in user browser (with 性能分析="user").
Browser Selection Tar获取 When to Use sandbox (default) OpenClaw's 清理 browser — no cookies, no 记录in 状态 host Browser 运行ning on the host machine node Browser on a pAIred remote node 性能分析 When to Use (omit) 清理 OpenClaw-managed browser 性能分析="user" Your own browser with active 记录ins (requires you present) Core Actions snapshot — Inspect the Page browser(action="snapshot", tar获取="sandbox")
Returns the full page DOM as a structured tree. Use refs="aria" for screen-reader-friendly selectors, refs="角色" (default) for 角色+name based refs.
browser( action="snapshot", tar获取="sandbox", refs="aria" )
screenshot — Capture the Page browser(action="screenshot", tar获取="sandbox")
For full-page screenshots:
browser( action="screenshot", tar获取="sandbox", fullPage=true )
navigate — Open a URL browser(action="navigate", tar获取="sandbox", url="https://news.ycombinator.com")
act — Interact with Elements
The act action is the workhorse. It combines ref (what to tar获取) + kind (action type) + 请求 (action detAIls).
命令行工具ck:
browser( action="act", tar获取="sandbox", ref="aria:Submit", 请求={"kind": "命令行工具ck"} )
Type:
browser( action="act", tar获取="sandbox", ref="id:搜索-box", 请求={"kind": "type", "text": "OpenClaw browser 自动化"} )
Press a key:
browser( action="act", tar获取="sandbox", ref="id:搜索-box", 请求={"kind": "press", "key": "Enter"} )
Hover:
browser( action="act", tar获取="sandbox", ref="css:.dropdown-menu", 请求={"kind": "hover"} )
Select from dropdown:
browser( action="act", tar获取="sandbox", ref="id:country-select", 请求={"kind": "select", "values": ["South Africa"]} )
WAIt for element:
browser( action="act", tar获取="sandbox", ref="aria:Loading", 请求={"kind": "wAIt", "timeMs": 5000} )
Locator Reference (ref types) Prefix Example Best For aria: aria:Submit 访问ible labels, buttons with text id: id:emAIl-输入 Unique element IDs css: css:.card:nth-child(2) Complex CSS selectors 角色: 角色:button[name="Submit"] Semantic 角色 selectors text: text:获取 启动ed Visible text content xpath: xpath://button[@class="btn"] Fallback for complex paths
For stable refs across calls, prefer refs="aria" in snapshots — these use ARIA labels that rarely change.
Recipes Recipe 1: Scrape a Dynamic Page // 1. Navigate browser(action="navigate", tar获取="sandbox", url="https://news.ycombinator.com/news")
// 2. WAIt for content to load browser( action="act", tar获取="sandbox", load状态="networkidle", ref="css:.item列出", 请求={"kind": "wAIt", "timeMs": 3000} )
// 3. Snapshot to 提取 structured data browser(action="snapshot", tar获取="sandbox", refs="aria")
Recipe 2: Fill and Submit a Form // 1. Navigate to form browser(action="navigate", tar获取="sandbox", url="https://example.com/contact")
// 2. Fill 输入s browser(action="act", tar获取="sandbox", ref="id:name", 请求={"kind": "fill", "text": "Alice Smith"}) browser(action="act", tar获取="sandbox", ref="id:emAIl", 请求={"kind": "fill", "text": "alice@example.com"}) browser(action="act", tar获取="sandbox", ref="id:message", 请求={"kind": "fill", "text": "Hi, I'd like to know more..."})
// 3. 命令行工具ck submit browser(action="act", tar获取="sandbox", ref="aria:Submit", 请求={"kind": "命令行工具ck"})
// 4. WAIt for confirmation browser( action="act", tar获取="sandbox", ref="aria:Thank you", 请求={"kind": "wAIt", "timeMs": 2000} )
Recipe 3: 记录in to a 服务 (User Browser) // Requires you to be present at the machine — uses your actual browser 会话 browser(action="navigate", tar获取="host", url="https://github.com/记录in")
browser(action="act", tar获取="host", ref="id:记录in_field", 请求={"kind": "fill", "text": "myuser"}) browser(action="act", tar获取="host", ref="id:password", 请求={"kind": "fill", "text": "mypassword"}) browser(action="act", tar获取="host", ref="css:[type=submit]", 请求={"kind": "命令行工具ck"})
Recipe 4: 监控 Price / AvAIlability // Navigate and wAIt for price to 更新 browser(action="navigate", tar获取="sandbox", url="https://example.com/product/123")
browser( action="act", tar获取="sandbox", ref="css:.price", 请求={"kind": "wAIt", "timeMs": 10000} )
// Capture screenshot browser(action="screenshot", tar获取="sandbox")
// Evaluate for price text browser( action="act", tar获取="sandbox", 请求={ "kind": "evaluate", "fn": "() => document.查询Selector('.price').innerText" } )
Recipe 5: Multi-Tab 工作流 // Open new tab browser(action="navigate", tar获取="sandbox", url="https://mAIl.google.com")
// Switch tabs browser(action="act", tar获取="sandbox", 请求={"kind": "press", "key": "Control+Tab"})
// Close current tab browser(action="act"