SuperAPI AI Directory

corrinehu-kimi-usebrowser

Agents & models

View repository

Updated 10-15 20:28

About this skill

Kimi Browser Automation Usage Guide

Overview

This skill summarizes the experience of using agent-browser for browser automation in the Kimi CLI environment, especially for common issues and solutions.

Core Workflow

Basic Usage Patterns

# 1. 打开网页
npx agent-browser open <url>

# 2. 等待页面加载
npx agent-browser wait --load networkidle

# 3. 获取页面快照(带交互元素引用)
npx agent-browser snapshot -i
4. Interactive operations (using references like @e1, @e2)

npx agent-browser fill @e1 "text" npx agent-browser click @e2

5. Screenshot

npx agent-browser screenshot output.png --full


### 命令链式执行

使用 `&&` 连接多个命令提高效率:

```bash
npx agent-browser open https://example.com && \
npx agent-browser wait --load networkidle && \
npx agent-browser snapshot -i

Common Issues and Solutions

Issue 1: First-time installation timeout

Symptom:

npx agent-browser open https://example.com
# Error: Command killed by timeout

Cause:npx On first run, it needs to download and install the agent-browser package and its 184+ dependencies.

Solution:

  • Install manually to a local directory:npm install agent-browser
  • Or use a longer timeout
  • After installation, subsequent uses will be faster

Issue 2: Playwright browser download failure

Symptom:

npx playwright install chromium
# Error: Proxy connection ended before receiving CONNECT response

Cause:agent-browser is based on Playwright and by default needs to download the Chromium browser, but may encounter network/proxy issues.

Solution: Use the system-installed Chrome

# 检查系统 Chrome
which google-chrome  # 或 chromium, chromium-browser

# 使用系统 Chrome 运行
npx agent-browser --executable-path /usr/bin/google-chrome open <url>

Important: If the daemon is already running, it needs to be closed first:

npx agent-browser close
sleep 1
npx agent-browser --executable-path /usr/bin/google-chrome open <url>

Issue 3: Session conflict

Symptom:--executable-path ignored: daemon already running

Solution: Close the existing session and restart:

npx agent-browser close
npx agent-browser --executable-path /usr/bin/google-chrome open <url>

Utility Script

Use scripts/check-browser-env.sh to quickly check the environment:

# 检查系统浏览器并输出建议命令
./scripts/check-browser-env.sh

Example output:

找到系统浏览器: /usr/bin/google-chrome
建议命令:
  npx agent-browser --executable-path /usr/bin/google-chrome open <url>

Complete example: search and take a screenshot

# 安装依赖(首次)
cd /tmp && npm install agent-browser

# 使用系统 Chrome 执行
npx agent-browser --executable-path /usr/bin/google-chrome open https://www.baidu.com
npx agent-browser wait --load networkidle
npx agent-browser snapshot -i

# 填写搜索框并搜索(假设 @e13 是搜索框,@e14 是按钮)
npx agent-browser fill @e13 "OpenAI"
npx agent-browser click @e14
npx agent-browser wait --load networkidle

# 截图
npx agent-browser screenshot /tmp/search_result.png --full

Quick Reference

Command Purpose
open <url> Open a webpage
close Close the browser
snapshot -i Get a snapshot of interactive elements
fill @eN "text" Fill in an input field
click @eN Click an element
wait --load networkidle Wait for the network to be idle
screenshot <path> --full Full-page screenshot

Environment Checklist

Before starting browser automation, check:

  1. agent-browser whether it is installed (npm list agent-browser)
  2. System Chrome/Chromium path (which google-chrome)
  3. whether there is a leftover daemon (npx agent-browser close cleanup)
  4. whether the network connection is normal