lecture 11 of 150 completed

File uploads and downloads

Both are common in real apps and awkward to test. Here is the working approach for each, and what to assert.

What you'll learn

  • How to attach a file without touching the file dialog
  • How to check a download actually contains the right data
  • What to assert after an upload

Upload and download appear in almost every business app: import a CSV of contacts, export an invoice, attach a document. Both are more awkward to test than they look, for the same reason: the file dialog belongs to the operating system, not the page, and no browser automation tool can click it.

Uploads.

You do not click "Browse". You attach the file to the input element directly. Modern Cypress has a command for it:

members only

Keep reading with the full course

The Foundations track and the first 5 lectures of each framework are free. This lecture is part of the paid course, which unlocks every lecture, all three frameworks, and downloads.

See the options →