VLearnVibium

How to Upload a File in Vibium

Upload a file in Vibium with el.setFiles(path) on a file input. Runnable Python examples for single, multiple, and hidden file inputs.

By Pramod Dutta··3 min read·Verified with Vibium 26.2
▶ Animated overview · made with Remotion

To upload a file in Vibium, find the file input and call setFiles() with the path, like vibe.find("input[type=file]").setFiles("/path/to/report.pdf"). Vibium sets the input's file list directly instead of clicking the button and wrestling with the operating system's native file picker. That distinction matters: the OS dialog cannot be automated reliably in headless or CI environments, so most flaky upload tests come from trying to drive it. By writing the FileList programmatically and dispatching the change event, Vibium makes uploads work identically headless or headed, locally or in CI. You can upload a single file by passing one path, or multiple files by passing a list (the input must carry the multiple attribute). It even works on hidden file inputs that a styled "Upload" button triggers, since you target the underlying <input type="file"> directly. The runnable patterns are below.

How do I upload a single file?

Find the <input type="file"> and call setFiles() with the absolute path to your file.

from vibium import browser_sync as browser
 
vibe = browser.launch()
vibe.go("https://example.com/upload")
 
file_input = vibe.find("input[type=file]")
file_input.setFiles("/Users/me/documents/report.pdf")
 
vibe.find(role="button", text="Submit").click()
 
vibe.quit()

Use an absolute path so the upload works no matter which directory the script runs from. Vibium sets the file list and fires the change event, so any JavaScript that previews the file or enables the submit button reacts exactly as it would for a manual selection. See How to Find Elements in Vibium for targeting the input reliably.

How do I upload multiple files?

Pass a list of paths to setFiles(). The input must allow multiple files (its multiple attribute must be set) for the browser to accept more than one.

from vibium import browser_sync as browser
 
vibe = browser.launch()
vibe.go("https://example.com/gallery/upload")
 
uploader = vibe.find("input[type=file][multiple]")
uploader.setFiles([
    "/Users/me/photos/sunrise.png",
    "/Users/me/photos/sunset.png",
])
 
vibe.quit()

If the input does not have the multiple attribute, the browser keeps only the last file — that is a browser rule, not a Vibium limitation. For single-file inputs, pass one path (a string) instead of a list.

How do I upload to a hidden file input?

Many sites hide the real <input type="file"> behind a styled button. You do not click the button — you target the hidden input directly and call setFiles().

from vibium import browser_sync as browser
 
vibe = browser.launch()
vibe.go("https://example.com/profile")
 
# the visible "Choose photo" button is just a label;
# target the real input behind it
hidden_input = vibe.find("#avatar-input")
hidden_input.setFiles("/Users/me/photos/avatar.png")
 
vibe.quit()

Because setFiles() works on the input element itself rather than the click that would open the picker, a hidden or visually-styled input is no obstacle. This is also why uploads do not block on a native OS dialog — there is no dialog in the loop at all, which keeps headless and CI runs reliable. To download files instead, see How to Download a File.

Why setFiles() beats driving the OS dialog

  • No native picker — the upload never opens an OS file dialog, so it works headless and in CI.
  • Fires change events — page logic (previews, validation, enabling submit) reacts as it would to a real selection.
  • Works on hidden inputs — target the underlying <input type="file">, not the styled button.

Always prefer setFiles() over trying to automate the system file chooser; it is the documented, reliable path.

Next steps

Frequently asked questions

How do I upload a file in Vibium?

Find the file input and call setFiles() with the path, for example vibe.find('input[type=file]').setFiles('/path/to/report.pdf'). Vibium sets the input's file list directly without opening the OS file picker, so the upload works the same headless or headed and never blocks on a native dialog.

Can I upload multiple files in Vibium?

Yes. Pass a list of paths to setFiles(), for example setFiles(['a.png', 'b.png']). The input must allow multiple files (the multiple attribute) for the browser to accept more than one. Vibium populates the file list and dispatches the change event so the page reacts as it would to a real selection.

How does Vibium upload without the OS file dialog?

setFiles() sets the file input's FileList programmatically rather than clicking the button and driving the native picker. This avoids the OS dialog entirely, which is what makes file upload reliable in CI and headless runs where no window manager is available to interact with a system dialog.

Vibium is created by Jason Huggins. This is an independent tutorial — see the official Vibium site and GitHub repo for canonical docs.

Related guides