代理浏览器

人工智能 社区

技能解读

当前原文的自动摘译,尚未人工审校。

何时使用

修改前端代码后验证视觉变化测试表单交互和用户流程捕获屏幕截图以进行文档或调试检查渲染的 HTML/辅助功能树调试为什么某些内容在浏览器中不起作用

2. 拍摄快照

snapshot 命令返回一个可访问性树,其中包含可用于交互的引用(@e1、@e2 等):

3. 使用参考进行交互

使用快照中的 @ref 值与元素交互:

4. 截图

在尝试加载之前始终检查图像大小。如果大于2MB,请使用sips或ImageMagick等工具处理以减小大小。您的工具无法加载大文件。

会议

会话在命令之间保留浏览器状态(cookie、存储):

流狐档案 运行与权限由流狐静态检查推断,不代表作者声明或实际测试结果。
领域
人工智能
作者声明的智能体
未找到明确声明;不据此推断已兼容或已测试
静态检查
88 / 100 · 启发式扫描,不代表运行安全
运行环境证据
未执行;当前没有隔离运行测试证据
作者 / 版本 / 许可证
@emdash-cms · 未声明许可证
上下文用量评级
低消耗
接入复杂程度
即装即用
是否需要外部接口密钥
不需要
兼容的系统
未声明(默认跨平台)
运行环境要求
未检出明确要求
检测到的文件与系统行为
  • 只读
  • 允许写入 / 修改
网络行为
仅限本地
安装命令数
无(仅作为资料)

需要注意: 未声明工具权限范围;实际权限由运行环境决定。

作者说明文件(原文) SKILL.md

# Agent Browser Skill

Fast browser automation CLI for AI agents. Use this to verify web UI changes, test interactions, and capture screenshots.

## When to Use

- Verify visual changes after modifying frontend code
- Test form interactions and user flows
- Capture screenshots for documentation or debugging
- Inspect rendered HTML/accessibility tree
- Debug why something isn't working in the browser

## Core Workflow

### 1. Open a URL

```bash
agent-browser open http://localhost:4321/
```

### 2. Take a Snapshot

The snapshot command returns an accessibility tree with refs (`@e1`, `@e2`, etc.) that you can use for interactions:

```bash
agent-browser snapshot -i    # -i = interactive elements only (recommended)
agent-browser snapshot -c    # -c = compact (removes empty structural elements)
agent-browser snapshot -i -c # Both flags work together
```

### 3. Interact Using Refs

Use the `@ref` values from the snapshot to interact with elements:

```bash
agent-browser click @e5           # Click element
agent-browser fill @e3 "hello"    # Clear and type
agent-browser type @e3 "world"    # Type without clearing
agent-browser select @e7 "option" # Select dropdown
agent-browser check @e9           # Check checkbox
```

### 4. Screenshot

```bash
agent-browser screenshot              # Viewport only
agent-browser screenshot --full       # Full page
agent-browser screenshot output.png   # Save to file
```

ALWAYS check the image size before attempting to load. If it is larger than 2MB, process it using a tool such as sips or ImageMagick to reduce the size. Large files cannot be loaded by your tools.

## Common Patterns

### Form Verification

```bash
agent-browser open http://localhost:4321/_emdash/api/setup/dev-bypass?redirect=/_emdash/admin/content/posts/new
agent-browser snapshot -i   # Check what fields are visible
agent-browser fill @e3 "Test Title"
agent-browser fill @e5 "Test content here"
agent-browser click @e7     # Save button
```

### Get Element Info

```bash
agent-browser get text @e1      # Get text content
agent-browser get html @e1      # Get inner HTML
agent-browser get value @e2     # Get input value
agent-browser get url           # Current URL
agent-browser get title         # Page title
agent-browser get count "button" # Count matching elements
```

### Check Element State

```bash
agent-browser is visible @e1
agent-browser is enabled @e2
agent-browser is checked @e3
```

### Find by Role/Label

```bash
agent-browser find role button click --name "Submit"
agent-browser find label "Email" fill "test@example.com"
agent-browser find placeholder "Search..." type "query"
```

## Sessions

Sessions keep browser state (cookies, storage) between commands:

```bash
# Use named session (persists until closed)
agent-browser --session mytest open http://localhost:4321
agent-browser --session mytest snapshot -i

# Or set via environment
export AGENT_BROWSER_SESSION=mytest
agent-browser open http://localhost:3000
```

## Useful Options

| Option             | Description                         |
| ------------------ | ----------------------------------- |
| `--session <name>` | Isolated browser session            |
| `--headed`         | Show browser window (not headless)  |
| `--json`           | JSON output for programmatic use    |
| `--full`           | Full page screenshot                |
| `-i`               | Snapshot: interactive elements only |
| `-c`               | Snapshot: compact output            |
| `-d <n>`           | Snapshot: limit tree depth          |

## Debugging

```bash
agent-browser --headed open http://localhost:3000  # See what's happening
agent-browser console                               # View console logs
agent-browser errors                                # View page errors
agent-browser highlight @e5                         # Highlight element
agent-browser eval "document.title"                 # Run JS
```

## Tips

1. **Always snapshot first** - Get refs before interacting
2. **Use `-i` flag** - Interactive-only snapshots are much cleaner
3. **Wait when needed** - Use `wait <ms>` or `wait <selector>` after actions that trigger loading
4. **Sessions for auth** - Use named sessions to persist login state
5. **Headed for debugging** - Use `--headed` when things aren't working as expected

讨论

基于 GitHub Discussions。登录 GitHub 即可参与讨论、点赞、订阅更新。