mirror of
https://github.com/Skyvern-AI/skyvern.git
synced 2026-05-01 21:20:19 +00:00
30 lines
1.1 KiB
Text
30 lines
1.1 KiB
Text
---
|
|
title: upload_file
|
|
slug: sdk-reference/browser-automation/upload-file
|
|
---
|
|
|
|
Upload one or more files to a file input. Pass a selector for direct Playwright behavior, a prompt for AI-powered file input detection, or both. Python only.
|
|
|
|
```python
|
|
# Direct selector
|
|
await page.upload_file("#file-input", files="/path/to/file.pdf")
|
|
|
|
# Multiple files
|
|
await page.upload_file("#file-input", files=["/path/to/file1.pdf", "/path/to/file2.pdf"])
|
|
|
|
# AI-powered file input detection
|
|
await page.upload_file(prompt="Upload the resume to the file input")
|
|
|
|
# Selector with AI fallback
|
|
await page.upload_file("#file-input", files="/path/to/file.pdf",
|
|
prompt="Upload the resume to the file input")
|
|
```
|
|
|
|
| Parameter | Type | Required | Description |
|
|
|-----------|------|----------|-------------|
|
|
| `selector` | `str` | No | CSS or XPath selector for the file input. |
|
|
| `files` | `str \| list[str]` | No | File path or list of file paths to upload. |
|
|
| `prompt` | `str` | No | Natural-language description of the file input to target. |
|
|
| `ai` | `str` | No | Controls AI behavior. Default `"fallback"` tries the selector first, then AI. |
|
|
|
|
Returns `str` - the resolved selector used.
|