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

  1. Add a File upload step with a source (see Sources below). The scalar form fileUpload: <path> works when you don’t need to rename.
  2. (Optional) Set name ( File name) to the name the page sees. The file name defaults to the name in the URL or local path.
  3. 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

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

  1. Add a Click step on the button or link that triggers the download.
  2. Set waitForDownload: true ( Wait for download) on that step. Momentic waits for the download to complete before moving on.
  3. (Optional) Set saveAs ( Save to environment variable, e.g. DOWNLOADED_FILE) to capture the return value. Its downloadedFile field contains the file URI. Later steps can reference it, including a File upload step via {{ env.DOWNLOADED_FILE.downloadedFile }}.

Limits

Round-trip: download then upload

Download a file from one part of the app and upload it somewhere else in the same test.

  1. Click (download button) with Wait for download on and Save to environment variable set to DOWNLOADED_FILE.
  2. File upload with source {{ env.DOWNLOADED_FILE.downloadedFile }}.
  3. Click (the button that opens the next file picker).