upload
The upload action sets the files of a file input (<input type="file">). It replaces any files the input already holds. The operating system’s file dialog never opens, so the step runs unattended and headless.
Use it for a procedure step such as “Choose your avatar image”. A click on a file input fails, and type can’t fill one.
For comprehensive options, see the
uploadreference.
Properties
upload takes an object with path and at least one field that finds the element.
Find the input
Many pages hide the file input and style its label as a button. upload works with a hidden input, so you can target either one:
- The input, with
selector,elementId, orelementTestId. - The label, with
elementText. The step then uses the input that belongs to the label.
Some pages open the dialog from a script instead, so the button you see isn’t a label. Target the input itself, which is often hidden near the button.
A drop zone works when it has a file input behind it. If it has no file input, upload can’t fill it.
Platform support
upload works in desktop browsers. In a mobile browser, the step is SKIPPED, because the file isn’t on the device.