Files - Momentic
File upload
Use the File upload step to hand a file to the next native file picker that opens on the page.
The step installs a listener on the next file picker. It must run before the picker is triggered, otherwise nothing is uploaded.
steps:
- fileUpload:
path: https://files.example.com/fixtures/notes.md
name: notes.md # optional: rename the file as presented to the page
- click: The "Choose file" button # opens the picker the upload feeds
Setup
- Add a File upload step with a source (see Sources below). The scalar form
fileUpload: <path>works when you don’t need to rename. - (Optional) Set
name( File name) to the name the page sees. The file name defaults to the name in the URL or local path. - Add a Click step on the button or element that opens the picker.
Sources
Remote URL
http:// or https://
Any publicly accessible direct file URL. Must resolve to the file itself, not an HTML wrapper or redirect.
https://files.example.com/fixtures/notes.md
Previously downloaded file
file://
Read downloadedFile from an earlier download step’s saved return value. The value already includes file://.
{{ env.DOWNLOADED_FILE.downloadedFile }}
Local file
path
Absolute path, or path relative to the CLI’s working directory. CLI only.
This differs from JavaScript and auth-state references, which resolve from the YAML file containing the step.Use fixtures/notes.md for a relative local file. In simplified YAML,
./notes.md, ../notes.md, and momentic://notes.md refer to files uploaded
to Momentic by name, rather than files on your machine.
Uploaded file
momentic://
A file uploaded to your Momentic organization. Use the uploaded name, for example fileUpload: momentic://notes.md.
Limits
- One file per step.
- Max file size: 50 MiB.
File download
Momentic captures a download by attaching to the Click step that triggers it, rather than a separate step type.
steps:
- click:
on: The "Export CSV" button
waitForDownload: true # wait for the download to finish before moving on
saveAs: DOWNLOADED_FILE # save the click return value for later steps
Setup
- Add a Click step on the button or link that triggers the download.
- Set
waitForDownload: true( Wait for download) on that step. Momentic waits for the download to complete before moving on. - (Optional) Set
saveAs( Save to environment variable, e.g.DOWNLOADED_FILE) to capture the return value. ItsdownloadedFilefield contains the file URI. Later steps can reference it, including a File upload step via{{ env.DOWNLOADED_FILE.downloadedFile }}.
Limits
- One file per Click step.
- Download timeout: 30 seconds by default. Set
click.downloadTimeoutin milliseconds to change it. - The step returns a file reference for reuse in the same session. It does not validate the file’s contents or format.
- The saved download is deleted after 5 minutes. Reuse it before that deadline.
Round-trip: download then upload
Download a file from one part of the app and upload it somewhere else in the same test.
- Click (download button) with Wait for download on and Save to environment variable set to
DOWNLOADED_FILE. - File upload with source
{{ env.DOWNLOADED_FILE.downloadedFile }}. - Click (the button that opens the next file picker).