DocsFile Operationsbrowser_upload_file

browser_upload_file

Browser Upload File

Upload files to a file input element. Programmatically sets the files on an input[type='file'] element. Supports multiple files if the input accepts them. File paths must be absolute paths on the server.

Usage Example

12345678910111213
import asyncio
from owl_browser import OwlBrowser, RemoteConfig
# Async usage
async with OwlBrowser(config) as browser:
context = await browser.create_context()
context_id = context["context_id"]
await browser.upload_file(
context_id=context_id,
selector="#element-id",
file_paths="value"
)

Parameters

Required

context_idstringrequired

The unique identifier of the browser context (e.g., 'ctx_000001')

selectorstringrequired

CSS selector for the file input element (e.g., 'input[type="file"]', '#file-upload')

file_pathsstringrequired

Array of file paths to upload. Can be a JSON array string or actual array. For JSON input use server paths. For multipart upload, files are saved to temp paths automatically.

Response

Returns a JSON object with the operation result.

{
  "success": true,
  "result": <value>
}