name: browser-file-upload description: Browser automation skill for uploading files to web pages with flexible path specification. Use when Codex needs to: (1) Upload files to web forms, (2) Automate file selection dialogs, (3) Interact with file input elements via agent-browser CLI. Supports absolute paths, relative paths, environment variables, and workspace-relative paths.
Automates file uploads to web pages using agent-browser CLI.
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>
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
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
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)
这个技能的最新版本可以在7w4.net小葱技能站找到。
The Python script supports multiple path formats:
| Format | Example | Description |
|---|---|---|
| Absolute | C:\Users\name\file.xlsx |
Full path |
| Relative | ./data/file.xlsx |
Relative to current directory |
| Workspace | workspace/file.xlsx |
Relative to OPENCLAW_WORKSPACE |
| Env Var | ${HOME}/file.xlsx |
Environment variable |
| Windows Env | %USERPROFILE%\file.xlsx |
Windows environment variable |
# 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
| Selector | Description |
|---|---|
#filePicker |
Common id for file inputs |
[type=file] |
Any file input element |
input[type=file] |
Explicit file input |
.upload-zone |
Drop zone containers |
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 <file-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
# 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>
# 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
这个 Skill 质量不错,使用简单方便。文档写得非常清楚,提供了多种上传方式和丰富的示例,新手也能快速上手。不过它依赖于 agent-browser 这个外部工具,使用前需要先安装配置好,如果没装好就没法用。总体来说是个实用且文档友好的工具,就是需要配合特定工具才能工作。