hubcap upload

Upload files to a file input element.

When to use

Use upload to set files on a <input type="file"> element. Provide the file input selector and one or more local file paths. The command simulates the browser file-selection dialog without user interaction.

Usage

hubcap upload <selector> <file>...

Arguments

ArgumentTypeRequiredDescription
selectorstringYesCSS selector of the file input element
filestringYesOne or more file paths to upload

Flags

None.

Output

FieldTypeDescription
uploadedbooleanWhether the upload succeeded
selectorstringThe selector of the file input
filesarrayList of file paths that were uploaded
{"uploaded":true,"selector":"#avatar","files":["photo.png"]}

Errors

ConditionExit codeStderr
Element not found1error: element not found: <sel>
Chrome not connected2error: connecting to Chrome: ...
Timeout3error: timeout

Examples

Upload a single file:

hubcap upload '#avatar' photo.png

Upload multiple files:

hubcap upload '#attachments' doc.pdf image.jpg

Upload using a full path:

hubcap upload '[type="file"]' /tmp/report.csv

Upload a file then click the submit button:

hubcap upload '#resume' ./resume.pdf && hubcap click '#apply'

See also

  • fill - Fill a text input
  • click - Click an element
  • forms - Get all form elements on the page