mcpField
A
agent-browser-automate

agent-browser-automate

github.com/owenleezyAgent 工作流461 次安装31 周前更新
代码仓库

关于 agent-browser-automate

这是一套使用 agent-browser 执行浏览器自动化的技能指南,涵盖表单、文件、标签页、身份验证和故障恢复,并为敏感操作设置检查点。

主要功能

  1. 01表单填写与提交检查
  2. 02文件上传和下载流程
  3. 03身份验证设置与恢复
  4. 04多标签页和剪贴板操作
  5. 05等待与故障恢复模式

适用场景

  1. 01提交前核对表单内容
  2. 02上传附件或保存下载报告
  3. 03处理登录过期和浏览器对话框

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/owenleezy/agent-browser-skill --skill agent-browser-automate

安装后在 Claude Code 中输入/agent-browser-automate确认已加载。

详细介绍

任务自动化 — 执行协议

内部模板。 入口:agent-browser 技能。


切勿

NEVER use `fill` when you want to append — it clears first; use `type` to append
NEVER upload a file with `click` then `fill` — use dedicated `upload <sel> <path>` command
NEVER submit a form without showing field values first — judgment gate required

身份验证设置(按优先级选择其一)

# Option 1 (recommended): Auth Vault — encrypted, reusable
agent-browser auth login <vault-name>
agent-browser open <url>

# Option 2: Persistent profile (local only)
agent-browser --profile ~/.myapp open <url>

# Option 3: Token injection
agent-browser open <url>
agent-browser storage local set authToken "<token>"
agent-browser reload

# Option 4: HTTP Basic Auth
agent-browser open <url>
agent-browser set credentials <user> <pass>

# Option 5: Bearer header
agent-browser --headers '{"Authorization":"Bearer <token>"}' open <url>

表单自动化流程

agent-browser snapshot -i                                    # get refs
agent-browser find label "Email" fill "[email protected]"
agent-browser find label "Password" fill "<password>"
agent-browser find role button click --name "Submit"
agent-browser wait --load networkidle
agent-browser screenshot --full step-complete.png           # evidence

文件操作

# Upload
agent-browser find label "Attachment" upload ./file.pdf

# Download (triggers on button click, waits for completion)
agent-browser find role button click --name "Export CSV"
agent-browser wait --download ~/report.csv

# Generate PDF
agent-browser pdf ./report.pdf

多标签页流程

agent-browser tab new
agent-browser open <second-url>
agent-browser tab 0       # switch back to first tab (0-based index)
agent-browser tab list    # see all tabs with URLs

剪贴板

# Read clipboard
agent-browser clipboard read

# Write to clipboard
agent-browser clipboard write "text to copy"

# Copy element text to clipboard
agent-browser clipboard copy @e3

# Paste clipboard into element
agent-browser clipboard paste @e5

# macOS: paste system clipboard into focused element
agent-browser keyboard inserttext "$(pbpaste)"

精细鼠标控制(画布 / 看板 / 绘图应用)

agent-browser mouse move <x> <y>
agent-browser mouse down
agent-browser mouse move <x2> <y2>   # drag
agent-browser mouse up

等待模式

# Page load
agent-browser wait --load networkidle

# Wait for element to appear
agent-browser wait "#success-toast"

# Wait for element to disappear (loading spinner)
agent-browser wait "#spinner" --state hidden

# Wait for URL to change (after form submit / redirect)
agent-browser wait --url "**/dashboard"

# Wait for text to appear
agent-browser wait --text "Upload complete"

# Wait for download to finish
agent-browser wait --download ./report.xlsx

恢复模式

故障恢复方法
身份验证已过期使用 auth login <name> 重新进行身份验证
Auth Vault 密码已更改使用 auth delete <name>,然后使用 auth save <name>
出现意外弹窗/对话框使用 dialog status 确认,然后使用 dialog dismiss
fill 覆盖现有内容使用 type 追加内容
模态框无法滚动使用 scroll down --selector ".modal-body"

判断关卡

以下情况请暂停:

  • 即将提交表单(显示字段值 → 请求确认)
  • 即将触发下载 / 删除 / 付款
  • 重试后身份验证仍失败(需要新的凭据)

易犯错误

错误修正方法
Auth Vault 密码已更改再次执行 auth delete + auth save — 不支持原位更新
fill 意外清除内容使用 type 追加内容
文件上传失败使用 find label "..." upload <path>,不要先 click 再 fill
无法在模态框内滚动使用 scroll down --selector ".modal-body"
未捕获下载点击下载按钮后,使用 wait --download <path>
JS 对话框完全阻塞守护进程Playwright 在 CDP 层拦截 — eval "window.confirm = () => true" 无效(JS 层覆盖无法触及 CDP)。唯一可靠的修复方法是:在 click 阻塞时,必须通过第二个并发进程调用 dialog accept。
快照中缺少只读 DOM 节点(没有 ARIA 角色的 <p>、<span>、<div>)snapshot 只呈现无障碍树 — 仅包含可交互元素。使用 eval "document.querySelector('#id').textContent" 或 eval "document.querySelector('.class').innerText" 读取非交互节点内容。

评论

支持 Markdown