agentleFS
rongxinzyrongxinzy/claude-code-best-practice-zh/.claude/skills/agent-browser/SKILL.md

agent-browser

Skill9 starsChanged 8 months agoMITView on GitHub

面向 AI 代理的浏览器自动化 CLI。当用户需要与网站交互时使用,包括导航页面、填写表单、点击按钮、截图、提取数据、测试 Web 应用程序或自动化任何浏览器任务。触发词包括"打开网站"、"填写表单"、"点击按钮"、"截图"、"从页面抓取数据"、"测试此 Web 应用"、"登录网站"、"自动化浏览器操作"或任何需要程序化 Web 交互的任务。

  • Installs packages

188 other projects use a version of this, 59 of them edited.

Adopted by

Most recently taken up by

Used with

Projects with it also use community-led-growth, ph-community-outreach and 8 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • nicepkgSkill

    community-led-growth

    Expert in community-led growth (CLG) - leveraging user communities to drive acquisition, retention, and expansion. Covers building developer communities, user groups, ambassador programs, and turning customers into advocates. Knows the difference between community as a feature vs community as a growth engine, and how to measure community ROI. Use when "community-led, CLG, ambassador program, champion program, user community, developer community, word of mouth, user group, " mentioned.

    Also in 5 projects that use this

  • nicepkgSkill

    ph-community-outreach

    Engage Reddit, Indie Hackers, Hacker News and other communities for Product Hunt launches. Use this skill to identify relevant communities, craft appropriate posts, and drive cross-platform engagement without appearing spammy.

    Also in 5 projects that use this

  • axiom-desuSkill

    dep-refs

    Use when needs to inspect TypeScript export references in the z-code workspace, list exports from a file, verify whether an export is unused before deletion, investigate who imports a symbol during refactors, or combine pnpm knip unused-export results with pnpm dep:refs symbol-level reference tracing.

    Also in 6 projects that use this

  • axiom-desuSkill

    feature-boundary-planner

    Map a ZCode behavior change to current UI surfaces, state owners, protocol commands, persistence, and validation. Use for impact analysis, product-boundary planning, or an implementation handoff grounded in the checked-out source.

    Also in 6 projects that use this

  • Maliot100XSkill

    send-user-message

    Send a proactive message to a paired user via their channel (Discord, Telegram, or WhatsApp). Use when the agent needs to notify, alert, or send an unsolicited message to a user — especially during heartbeat invocations, scheduled tasks, or when the agent wants to reach out without a prior user message in the current conversation. Triggers: 'send message to user', 'notify user', 'alert user', 'message the user on discord/telegram/whatsapp', or any need to proactively communicate with a paired sender.

    Also in 4 projects that use this

  • Cartograf666Skill

    architecture-governance

    Bootstrap, document, enforce, and review a project's architecture through layer responsibilities, dependency direction, architecture manifests, legacy baselines, Change Envelopes, cross-layer approval policy, and deterministic architecture checks. Use when starting a project, auditing an existing codebase, planning cross-layer work, preventing architecture erosion, reviewing structural changes, or deciding whether implementation may expand into another layer.

    Also in 6 projects that use this

  • +4 more from nicepkg

The file

Files
SKILL.md

使用 agent-browser 进行浏览器自动化

核心工作流程

每个浏览器自动化都遵循此模式:

  1. 导航:agent-browser open <url>
  2. 快照:agent-browser snapshot -i(获取元素引用如 @e1, @e2)
  3. 交互:使用引用进行点击、填写、选择
  4. 重新快照:在导航或 DOM 变化后,获取新的引用
agent-browser open https://example.com/form
agent-browser snapshot -i
# 输出:@e1 [input type="email"], @e2 [input type="password"], @e3 [button] "Submit"

agent-browser fill @e1 "user@example.com"
agent-browser fill @e2 "password123"
agent-browser click @e3
agent-browser wait --load networkidle
agent-browser snapshot -i  # 检查结果

基本命令

# 导航
agent-browser open <url>              # 导航(别名:goto, navigate)
agent-browser close                   # 关闭浏览器

# 快照
agent-browser snapshot -i             # 带引用的交互式元素(推荐)
agent-browser snapshot -i -C          # 包含光标交互式元素(带 onclick、cursor:pointer 的 div)
agent-browser snapshot -s "#selector" # 限定到 CSS 选择器

# 交互(使用来自 snapshot 的 @refs)
agent-browser click @e1               # 点击元素
agent-browser fill @e2 "text"         # 清除并输入文本
agent-browser type @e2 "text"         # 不清除直接输入
agent-browser select @e1 "option"     # 选择下拉选项
agent-browser check @e1               # 勾选复选框
agent-browser press Enter             # 按键
agent-browser scroll down 500         # 滚动页面

# 获取信息
agent-browser get text @e1            # 获取元素文本
agent-browser get url                 # 获取当前 URL
agent-browser get title               # 获取页面标题

# 等待
agent-browser wait @e1                # 等待元素
agent-browser wait --load networkidle # 等待网络空闲
agent-browser wait --url "**/page"    # 等待 URL 模式匹配
agent-browser wait 2000               # 等待指定毫秒数

# 捕获
agent-browser screenshot              # 截图到临时目录
agent-browser screenshot --full       # 全页面截图
agent-browser pdf output.pdf          # 保存为 PDF

常见模式

表单提交

agent-browser open https://example.com/signup
agent-browser snapshot -i
agent-browser fill @e1 "Jane Doe"
agent-browser fill @e2 "jane@example.com"
agent-browser select @e3 "California"
agent-browser check @e4
agent-browser click @e5
agent-browser wait --load networkidle

带状态持久化的认证

# 登录一次并保存状态
agent-browser open https://app.example.com/login
agent-browser snapshot -i
agent-browser fill @e1 "$USERNAME"
agent-browser fill @e2 "$PASSWORD"
agent-browser click @e3
agent-browser wait --url "**/dashboard"
agent-browser state save auth.json

# 在未来的会话中复用
agent-browser state load auth.json
agent-browser open https://app.example.com/dashboard

数据提取

agent-browser open https://example.com/products
agent-browser snapshot -i
agent-browser get text @e5           # 获取特定元素文本
agent-browser get text body > page.txt  # 获取所有页面文本

# JSON 输出用于解析
agent-browser snapshot -i --json
agent-browser get text @e1 --json

并行会话

agent-browser --session site1 open https://site-a.com
agent-browser --session site2 open https://site-b.com

agent-browser --session site1 snapshot -i
agent-browser --session site2 snapshot -i

agent-browser session list

可视化浏览器(调试)

agent-browser --headed open https://example.com
agent-browser highlight @e1          # 高亮元素
agent-browser record start demo.webm # 录制会话

本地文件(PDF、HTML)

# 使用 file:// URL 打开本地文件
agent-browser --allow-file-access open file:///path/to/document.pdf
agent-browser --allow-file-access open file:///path/to/page.html
agent-browser screenshot output.png

iOS 模拟器(移动 Safari)

# 列出可用的 iOS 模拟器
agent-browser device list

# 在特定设备上启动 Safari
agent-browser -p ios --device "iPhone 16 Pro" open https://example.com

# 与桌面版相同的工作流程 - 快照、交互、重新快照
agent-browser -p ios snapshot -i
agent-browser -p ios tap @e1          # 点击(click 的别名)
agent-browser -p ios fill @e2 "text"
agent-browser -p ios swipe up         # 移动设备特定手势

# 截图
agent-browser -p ios screenshot mobile.png

# 关闭会话(关闭模拟器)
agent-browser -p ios close

要求: macOS 配合 Xcode,Appium(npm install -g appium && appium driver install xcuitest)

真机: 如果预先配置好,可以与实体 iOS 设备配合使用。使用 --device "<UDID>",其中 UDID 来自 xcrun xctrace list devices。

引用生命周期(重要)

引用(@e1, @e2 等)在页面变化时会失效。在以下情况后务必重新快照:

  • 点击链接或按钮进行导航
  • 表单提交
  • 动态内容加载(下拉菜单、模态框)
agent-browser click @e5              # 导航到新页面
agent-browser snapshot -i            # 必须重新快照
agent-browser click @e1              # 使用新的引用

语义定位器(引用的替代方案)

当引用不可用或不可靠时,使用语义定位器:

agent-browser find text "Sign In" click
agent-browser find label "Email" fill "user@test.com"
agent-browser find role button click --name "Submit"
agent-browser find placeholder "Search" type "query"
agent-browser find testid "submit-btn" click

深入文档

参考文档何时使用
references/commands.md完整的命令参考及所有选项
references/snapshot-refs.md引用生命周期、失效规则、故障排除
references/session-management.md并行会话、状态持久化、并发抓取
references/authentication.md登录流程、OAuth、双因素认证处理、状态复用
references/video-recording.md录制工作流用于调试和文档
references/proxy-support.md代理配置、地理测试、轮换代理

即用模板

模板描述
templates/form-automation.sh带验证的表单填写
templates/authenticated-session.sh一次登录,复用状态
templates/capture-workflow.sh带截图的内容提取
./templates/form-automation.sh https://example.com/form
./templates/authenticated-session.sh https://app.example.com/login
./templates/capture-workflow.sh https://example.com ./output

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.