← 返回
未分类 中文

browser-file-uploa

Automates file uploads on web pages via agent-browser CLI or Python script, supporting flexible file paths and optional file input selectors.
通过 agent-browser CLI 或 Python 脚本自动化网页文件上传,支持灵活的文件路径和可选的文件输入选择器。
weixizi
未分类 clawhub v1.0.0 1 版本 99665.6 Key: 无需
★ 0
Stars
📥 298
下载
💾 0
安装
1
版本
#latest

概述

Browser File Upload

Automates file uploads to web pages using agent-browser CLI.

Quick Start

Upload a file to a web page:

# Basic upload (auto-detects file input)
agent-browser open <url>
agent-browser find text 选择文件 click
agent-browser upload "#filePicker" <file-path>

# Or use the Python script
python scripts/upload_file.py <url> <file-path>

Usage Patterns

Upload to Specific Selector

When you know the file input selector:

agent-browser open https://example.com/upload
agent-browser click "#fileInput"
agent-browser upload "#fileInput" C:\path\to\file.xlsx

Upload by Text Search

When file input has visible label text:

agent-browser open https://example.com/upload
agent-browser find text "上传文件" click
agent-browser upload "[type=file]" C:\path\to\file.xlsx

Using Python Script

For reusable upload logic with flexible path specification:

python scripts/upload_file.py <url> <file-path> [selector] [wait_ms]

Arguments:

  • url - Target page URL
  • file-path - Path to file (supports multiple formats, see below)
  • selector - Optional CSS selector for file input
  • wait_ms - Optional wait time after page load (default: 2000)

File Path Formats

The Python script supports multiple path formats:

FormatExampleDescription
------------------------------
AbsoluteC:\Users\name\file.xlsxFull path
Relative./data/file.xlsxRelative to current directory
Workspaceworkspace/file.xlsxRelative to OPENCLAW_WORKSPACE
Env Var${HOME}/file.xlsxEnvironment variable
Windows Env%USERPROFILE%\file.xlsxWindows environment variable

Path Examples

# Absolute path
python scripts/upload_file.py https://example.com C:\Users\陈\Documents\data.xlsx

# Relative path (from workspace)
python scripts/upload_file.py https://example.com ./test.xlsx

# Workspace-relative
python scripts/upload_file.py https://example.com workspace/data/test.xlsx

# With environment variable
python scripts/upload_file.py https://example.com ${HOME}/downloads/file.xlsx

Common Selectors

SelectorDescription
-----------------------
#filePickerCommon id for file inputs
[type=file]Any file input element
input[type=file]Explicit file input
.upload-zoneDrop zone containers

Troubleshooting

File input not found:

  • Run agent-browser snapshot to inspect page elements
  • Look for [type=file] or file-related buttons
  • Try clicking the upload zone first

Upload fails:

  • Ensure file path is absolute
  • Check file exists: test-path
  • Try agent-browser find text 选择文件 click first

Page not loaded:

  • Add agent-browser wait 2000 after open
  • Use agent-browser wait --load networkidle for slow pages

Related Commands

# Inspect page elements
agent-browser snapshot

# Take screenshot
agent-browser screenshot

# Find elements by text
agent-browser find text "上传"

# Click element
agent-browser click <selector>

# Upload file
agent-browser upload <selector> <file-path>

Example: Upload Excel to UU Tool

# Method 1: Direct agent-browser commands
agent-browser open https://uutool.cn/excel/
agent-browser wait 2000
agent-browser find text 选择文件 click
agent-browser upload "#filePicker" C:\Users\陈\.openclaw\workspace\test.xlsx

# Method 2: Using Python script with absolute path
python scripts/upload_file.py https://uutool.cn/excel/ C:\Users\陈\.openclaw\workspace\test.xlsx

# Method 3: Using Python script with workspace-relative path
python scripts/upload_file.py https://uutool.cn/excel/ workspace/test.xlsx

# Method 4: Using Python script with custom selector and wait time
python scripts/upload_file.py https://uutool.cn/excel/ workspace/test.xlsx "#filePicker" 3000

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-05-07 13:23 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

dev-programming

Github

steipete
使用 `gh` CLI 与 GitHub 交互,通过 `gh issue`、`gh pr`、`gh run` 和 `gh api` 管理议题、PR、CI 运行及高级查询。
★ 676 📥 325,416
ai-agent

Skill Vetter

spclaudehome
AI智能体技能安全预审工具。安装ClawdHub、GitHub等来源技能前,检查风险信号、权限范围及可疑模式。
★ 1,226 📥 267,812
ai-agent

self-improving agent

pskoett
捕获经验教训、错误及修正内容,以实现持续改进。适用于以下场景:(1)命令或操作意外失败;(2)用户纠正Claude(如“不,那不对……”“实际上……”);(3)用户请求的功能不存在;(4)外部API或工具出现故障;(5)Claude发现自身
★ 4,081 📥 809,966