browser-file-upload
by @weixizi
Automates uploading files to web pages via agent-browser CLI, supporting flexible path formats and interactions with file input elements or dialogs.
clawhub install browser-file-uploadπ About This Skill
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.
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
agent-browser find text ιζ©ζδ»Ά click
agent-browser upload "#filePicker" Or use the Python script
python scripts/upload_file.py
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 [selector] [wait_ms]
Arguments:
url - Target page URLfile-path - Path to file (supports multiple formats, see below)selector - Optional CSS selector for file inputwait_ms - Optional wait time after page load (default: 2000)File Path Formats
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 |
Path Examples
# Absolute path
python scripts/upload_file.py https://example.com C:\Users\ι\Documents\data.xlsxRelative path (from workspace)
python scripts/upload_file.py https://example.com ./test.xlsxWorkspace-relative
python scripts/upload_file.py https://example.com workspace/data/test.xlsxWith environment variable
python scripts/upload_file.py https://example.com ${HOME}/downloads/file.xlsx
Common Selectors
| 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 |
Troubleshooting
File input not found:
agent-browser snapshot to inspect page elements[type=file] or file-related buttonsUpload fails:
test-path agent-browser find text ιζ©ζδ»Ά click firstPage not loaded:
agent-browser wait 2000 after openagent-browser wait --load networkidle for slow pagesRelated Commands
# Inspect page elements
agent-browser snapshotTake screenshot
agent-browser screenshotFind elements by text
agent-browser find text "δΈδΌ "Click element
agent-browser click Upload file
agent-browser upload
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.xlsxMethod 2: Using Python script with absolute path
python scripts/upload_file.py https://uutool.cn/excel/ C:\Users\ι\.openclaw\workspace\test.xlsxMethod 3: Using Python script with workspace-relative path
python scripts/upload_file.py https://uutool.cn/excel/ workspace/test.xlsxMethod 4: Using Python script with custom selector and wait time
python scripts/upload_file.py https://uutool.cn/excel/ workspace/test.xlsx "#filePicker" 3000
π‘ Examples
Upload a file to a web page:
# Basic upload (auto-detects file input)
agent-browser open
agent-browser find text ιζ©ζδ»Ά click
agent-browser upload "#filePicker" Or use the Python script
python scripts/upload_file.py
π Tips & Best Practices
File input not found:
agent-browser snapshot to inspect page elements[type=file] or file-related buttonsUpload fails:
test-path agent-browser find text ιζ©ζδ»Ά click firstPage not loaded:
agent-browser wait 2000 after openagent-browser wait --load networkidle for slow pages