browser-automation
openclaw/openclaw · Agent Skill
自動化網頁控制,包括複雜場景、登入檢查、標籤管理和錯誤處理。
前往安裝 ↓總覽
| 發布者 | |
|---|---|
| 儲存庫 | openclaw/openclaw ↗ |
| 技能資料夾 | browser-automation |
| 星 | 389,595 |
| 分支 | 81,898 |
| 附帶檔案 | 1 |
| 授權 | MIT |
| 最近更新 | 2026年9月13日 |
| 連結 | 技能原始碼 ↗ · 儲存庫 ↗ |
Mozgi 檢查
我們在技能檔案中發現的內容。詳細資訊需訂閱。
安裝
技能就是一個含 SKILL.md 的資料夾。選擇你的代理,在專案根目錄的終端機(macOS、Linux 或 Windows 的 Git Bash)執行指令。
把提示貼到 Claude、Codex 或其他助理:它會自行檢查並安裝技能。
Install the “browser-automation” skill from mozgi.io (https://mozgi.io/skills/browser-automation/) for me. 1. Download the archive: https://mozgi.io/skills/browser-automation/download If it fails, take the skill folder from the source: https://github.com/openclaw/openclaw/tree/main/extensions/browser/skills/browser-automation 2. Read SKILL.md and the other files. Check the skill is safe: no hidden commands, no sending data elsewhere, no scripts doing something other than described. If anything looks suspicious, stop and tell me. 3. Put the “browser-automation” folder into your agent's skills folder: .claude/skills/ for Claude Code, .agents/skills/ for Codex, .cursor/skills/ for Cursor, .gemini/skills/ for Gemini CLI. Inside the project if we are in one, otherwise in the home folder (~/.claude/skills/ etc.). 4. Make sure <skills folder>/browser-automation/SKILL.md exists. 5. Briefly tell me what this skill does and offer to try it on my task. If you cannot do a step yourself, tell me what to click or type.
git clone --depth 1 --branch main https://github.com/openclaw/openclaw.git /tmp/openclaw mkdir -p .claude/skills cp -r /tmp/openclaw/extensions/browser/skills/browser-automation .claude/skills/browser-automation
重新啟動 Claude Code — 技能就會出現在清單中,手動呼叫:/browser-automation。要套用到所有專案,請放在 ~/.claude/skills。
git clone --depth 1 --branch main https://github.com/openclaw/openclaw.git /tmp/openclaw mkdir -p .agents/skills cp -r /tmp/openclaw/extensions/browser/skills/browser-automation .agents/skills/browser-automation
Codex 會從目前資料夾往上到儲存庫根目錄,在 .agents/skills 中尋找技能;用 /skills 或 $browser-automation 呼叫。所有專案:~/.agents/skills。
git clone --depth 1 --branch main https://github.com/openclaw/openclaw.git /tmp/openclaw mkdir -p .cursor/skills cp -r /tmp/openclaw/extensions/browser/skills/browser-automation .cursor/skills/browser-automation
Cursor 啟動時會載入技能;在 Agent 聊天輸入「/」呼叫。Cursor 也會讀取 .claude/skills 與 .agents/skills。所有專案:~/.cursor/skills。
git clone --depth 1 --branch main https://github.com/openclaw/openclaw.git /tmp/openclaw mkdir -p .gemini/skills cp -r /tmp/openclaw/extensions/browser/skills/browser-automation .gemini/skills/browser-automation
任務符合時,Gemini CLI 會提議啟用技能,由你確認。所有專案:~/.gemini/skills。
安裝前請先檢視 SKILL.md 與相關檔案。點擊檔案即可預覽。
SKILL.md 內容
作者原文 · 唯讀Browser Automation
Use this skill when you need the browser tool for anything beyond a single page check.
Operating Loop
1. Check browser state before acting:
openclaw browser doctororaction="status"when the browser/plugin setup itself may be broken.action="status"for availability.action="profiles"if login state or profile choice matters.action="tabs"before opening a new tab if retries/timeouts may have left windows behind.
2. Prefer stable tab handles:
- Open important tabs with
label, for examplelabel="meet". - After
action="tabs"oraction="open", storesuggestedTargetIdand pass it astargetIdin later calls. suggestedTargetIdis the label when one exists, otherwise the stabletabIdhandle liket1.- Avoid relying on raw DevTools
targetIdexcept for immediate diagnostics; it can change under Chromium target replacement.
3. Read before you click:
- For “read the page and answer X,” use
action="text"with optionalselectorandmaxCharsfor bounded visible prose (first selector match, otherwise article/main/body). On existing-session profiles, usesnapshotinstead. Efficient snapshots omit most prose. - For virtualized lists, scroll through each segment, capture only the relevant rows, then merge the results.
- Use
action="snapshot"on the intendedtargetId. - Add snapshot
queryto find lines containing all query tokens, ignoring case; matching lines keep their refs. - Use the same
targetIdfor follow-up actions so refs stay on the same tab. - For durable Playwright refs, request
refs="aria"when supported. If you receiveaxNrefs fromsnapshotFormat="aria", use them only after that same snapshot call; stale or unboundaxNrefs fail fast and need a fresh snapshot. - Use
urls=truewhen link text is ambiguous or a direct navigation target would avoid brittle clicks. - Use
labels=trueon snapshot or screenshot when visual position matters. On Playwright-backed profiles, the response includes anannotationsarray ({ref, number, role, name?, box}) with each ref's bounding box in the captured image's coordinate space, so you can reason about position without re-snapshotting; screenshot labels can also combine withfullPage=true(CLI:--full-page) to label the whole document, orref/elementto clip to one element.profile="user"and other existing-session (chrome-mcp) profiles render an overlay into page screenshots but do not attachannotationsor use the Playwright full-page/ref/element projection helper, so read positions from the labeled image itself on those profiles. The raw-CDP fallback (no Playwright) does not support labeled screenshots at all and returns a 501, so only requestlabelswhen Playwright is available.
4. Act narrowly:
- Prefer
action="act"with a ref from the latest snapshot. navigatereturns the loaded page's compact snapshot inline, and batchactresults that report a cross-document navigation include fresh page state; use those refs directly instead of a follow-up snapshot call.- After a single act that triggers navigation, and after modal changes or form submissions, snapshot again before the next action.
- Avoid blind waits. Wait for visible UI state when possible.
- Use
action="emulate"withdevice,colorScheme,timezoneId, orlocalewhen testing those settings; snapshot again afterward. Existing-session profiles do not support emulation.
5. Report real blockers:
- Debug network failures with
action="requests", optional URL/typefilter, andlimit(default 50 recent entries).clear=trueclears the collected log after reading. Use a managed profile; existing-session profiles do not support this log. - Debug page errors with
action="errors"andlimit(default 50 recent entries).clear=trueclears the collected log after reading. Existing-session profiles do not support this log. - If the page needs login, permission, captcha, 2FA, camera/microphone approval, or another manual step, stop and tell the user exactly what is needed.
- Do not claim the browser is not logged in just because the current page shows a permission or onboarding dialog. Inspect the visible UI first.
Browser batch CLI
openclaw browser batch runs an array of nested /act actions in one /act call (the same kind="batch" runtime reached through the agent tool), so CLI users and scripts can combine actions like wait, click, type, and evaluate into a single replayable plan without per-action round trips. Each entry in actions[] is a BrowserActRequest — the closed union the /act route accepts — not arbitrary openclaw browser subcommands. batch is not supported on profile="user" and other existing-session (chrome-mcp) profiles; send actions individually there.
- CLI:
openclaw browser batch --actions '<json>',--actions-file plan.json, or--actions-file -for stdin.--actions-fileand stdin input are capped at 1,000,000 bytes; split larger plans into multiple batch commands.--continuesetsstopOnError=false; default stops on first error. - Ref lifecycle: refs come from a
snapshotrun before the batch (snapshot is not a nested action). A nested action that changes page state — such as aclickthat triggers navigation, or anevaluatethat mutates the DOM — can invalidate earlier refs for the rest of the batch; put state-changing actions first, or split into a follow-up batch after re-snapshotting. Navigation and re-snapshotting happen outside the batch, sinceopen,navigate, andsnapshotare not/actkinds. - Target id: nested actions share the request's tab; an explicit nested
targetIdthat resolves to a different tab is rejected withACT_TARGET_ID_MISMATCH. - Response:
{ "results": [{ "ok": true } | { "ok": false, "error": "..." }, ...] }in order; with defaultstopOnErrorthe array ends at the first failure. Any failed entry exits nonzero; use--jsonto preserve the full response in scripts.
Code Mode Loop
When tools.codeMode is enabled, the Browser tool has no normal turn — it is cataloged behind exec/wait. Call it from exec cells as an async global, using the callable name the exec quick index advertises for the Browser tool (normally browser; colliding names get suffixed, and a client tool can win an identical name). An exact catalog.search("browser") returns a handle already bound to the effective callable name, so resolve the handle in each cell and call it instead of hard-coding the literal global; an empty result means the Browser tool is not cataloged in this run.
Keep the same labeled tab through the loop, and alternate reads with actions. Each exec cell starts a fresh VM — bindings from a completed cell are gone in the next, and only runs left waiting keep their state until wait resumes them — so carry comparison state across cells by returning it and re-embedding the returned values in the next cell:
// previous = the url/newElements returned by the last completed cell (a fresh
// VM runs this cell, so prior bindings do not exist here).
const previous = { url: "https://example.com/inbox", newElements: 0 };
const [browser] = await catalog.search("browser", { limit: 1 });
const details = await browser({
action: "snapshot",
snapshotFormat: "ai",
targetId: "task",
refs: "aria",
interactive: true,
});
const changed =
details?.url !== previous.url ||
(details?.newElements ?? 0) > 0 ||
details?.blockedByDialog === true;
return {
targetId: details?.targetId,
url: details?.url,
newElements: details?.newElements,
stats: details?.stats,
changed,
};
- Code-mode calls return the tool's structured
detailsdirectly (targetId,url,newElements,stats,blockedByDialog); rendered page text is not returned to code cells. - To read text inside code mode, run a targeted
actevaluate (requires the evaluate capability;browser.evaluateEnabledcan disable it) and keep the returned value bounded, because page-script output is untrusted:
const [browser] = await catalog.search("browser", { limit: 1 });
const read = await browser({
action: "act",
kind: "evaluate",
fn: "() => document.body.innerText.slice(0, 2000)",
targetId: "task",
});
return { url: read?.url, text: read?.result };
When evaluate is unavailable, keep the loop on structured state only.
- Return only the fields the next step needs; never return the whole details object.
- Completed cells share no state: re-embed the previous cell's returned
url/newElementsin the next cell, or keep the comparison inside one cell. Onlywaitingruns persist, resumed bywait. - Interleave each act with a URL or tabs check before the next dependent act.
- If a batch returns
aborted, take a fresh snapshot before continuing. - If
newElementsis positive, inspect those elements first, then update the re-embedded state. - Use separate act calls when navigation is expected between steps.
Tab Hygiene
Before creating a tab for a named task, list tabs and reuse an existing matching label or URL when it is still usable.
Example:
{ "action": "tabs" }
If no suitable tab exists:
{ "action": "open", "url": "https://example.com", "label": "task" }
Then target it by label:
{ "action": "snapshot", "targetId": "task", "refs": "aria" }
If a retry creates duplicates, close the extras by tabId:
{ "action": "close", "targetId": "t3" }
Do not pass bare numbers like "2" as targetId. Numeric tab positions are only for the CLI openclaw browser tab select 2 helper; browser tool calls need a suggestedTargetId, label, tabId, or raw target id.
Stale Ref Recovery
If an action fails with a missing or stale ref:
1. Snapshot the same targetId again.
2. Find the current visible control.
3. Retry once with the new ref.
4. If the UI moved to a blocker state, report the blocker instead of looping.
Existing User Browser
Use profile="user" only when existing cookies/login matter. This attaches to the user's running Chromium-based browser.
On macOS, action="importprofile" is the alternative when the agent should use an isolated managed browser with cookies copied from a real Chrome-family profile. First use action="profiles" and inspect systemProfiles, then import into a fresh managed profile name. Import asks for one Keychain/Touch ID consent prompt. It copies cookies, not local storage or IndexedDB; device-bound session credentials (DBSC) mean some Google sessions may still require re-authentication.
For profile="user" and other existing-session profiles, omit timeoutMs on act:type, hover, scrollIntoView, drag, select, and fill; that driver rejects per-call timeout overrides for those actions. act:evaluate accepts timeoutMs.
Google Meet Notes
When creating or joining a Meet:
- Treat camera/microphone permission screens as progress, not login failure.
- If asked whether people can hear you, click the microphone option when voice is required.
- If Google asks for sign-in, 2FA, account chooser confirmation, or permission that needs user approval, report the exact manual action.
- Use one labeled tab per meeting flow, for example
label="meet", and reuse it during retries.
常見問題
browser-automation 技能有什麼用途?
自動化網頁控制,包括複雜場景、登入檢查、標籤管理和錯誤處理。
如何安裝 browser-automation?
打開本頁的「安裝」區塊並選擇你的代理 — Claude Code、Codex、Cursor 或 Gemini CLI:那裡有把技能資料夾複製到正確位置的現成指令。也可以複製「透過助理」分頁中的提示,讓助理自行檢查並安裝技能。
browser-automation 適用哪些 AI 模型?
技能是純 Markdown 指示(Agent Skills 格式),因此 browser-automation 適用任何讀取 SKILL.md 的代理:Claude Code、Codex、Cursor、Gemini CLI、GitHub Copilot、OpenCode 等。只有在任務符合技能描述時,模型才會載入指示。
browser-automation 是免費的嗎?
此技能由 openclaw 公開發布,採用 MIT 授權。技能本身免費 — 你只需向 AI 供應商支付實際使用的 token 費用。
安裝技能安全嗎?
技能是代理會遵循的指示,安裝前請閱讀 SKILL.md 及相關檔案。技能資料夾中的腳本只有在代理執行時才會運行 — 留意它的動作,不要授予多餘權限。
技能和 MCP 伺服器或外掛有何不同?
MCP 伺服器或外掛為模型提供新工具 — 會執行並回傳結果的程式碼。技能提供的是知識與流程:如何處理任務、要遵循哪些步驟、好的成果長什麼樣子。它不需要伺服器或 API 金鑰。