TOPIC 22/6018 MINNOT STARTED

Uploads and downloads

Attach a file to a task with setInputFiles, catch the file chooser, and wait for a download to check its name and content.

L1–L4 are part of the Pro pass

L0 Explain simply

Analogy: handing a parcel over and checking the one you got back. At a post counter you hand over a parcel. The clerk takes it and gives you a slip. Later you collect another parcel. You do not just look at the outside. You open it and check what is inside. You also check the label on the box.

Daily List is a to-do list app. A user can upload a file to a task, such as a photo of a receipt. That is handing a parcel over. The user can also download the task list as a file. That is collecting one. Tom, the tester, must check both directions.

The picture has limits. A parcel is one thing. A web download can be many files. It can fail halfway. The server can give it a new name each time.

What it is: Playwright is a free library from Microsoft. It drives a real browser from code, so a test can click and check a page the way a person would. This topic is one slice of that library: the calls for files. For an upload, Tom uses setInputFiles, which means "put this file into that file box". For a download, he starts a wait with page.waitForEvent('download'), clicks Export, then opens the file that arrived and reads it. These are Playwright calls, not a separate tool. The nearest neighbour is clicking the Export button and stopping there. That only shows that a click worked.

Why it matters: Upload and download paths fail in ways a click cannot show. A test that only clicks Export may pass while the file is empty. A test that sends a file may pass while the server rejects it. With these calls, Tom attaches an and checks the , including a CSV (comma-separated values) file, without any manual clicking. Without them, Mei would find an empty export only when a customer complained.

(SYNTHETIC / TRAINING ONLY: Daily List and every person named in this lesson are invented.)

PLAIN WORDS · 1 in this section
playwright
a free Microsoft tool that drives a browser for tests

PICTURE IT

The picture is the one the lesson above opens with. The table below shows how each part of it matches the software.

THE REAL JOB Sending a file in, and catching a file that comes out, then opening both to see what is inside.

  1. Pick a small file
  2. Wait before the click
  3. Save the download
  4. Open and check
Hand over, open the box

HOW THE PICTURE MAPS

How each part of the picture matches the software
In the pictureIn the software
Handing the parcel overThe upload
The slip you getThe page showing the file name
Collecting a parcelThe download
Opening the boxReading the saved file

WHERE THIS PICTURE STOPS

  • A parcel is one thing. A web download can fail halfway.
  • A clerk is a person. A browser raises events that a test must catch in time.
  • A parcel keeps its label. A server may offer a different file name each time.

HOOK

Hand it over, open the box.

REMEMBER IT THIS WAY

A rule of thumb: if you see this, think that.

After a download, open the file and check what is inside and the label, not only that a file arrived.

What each part of the trick stands for
In the trickWhat it stands for
Uploadhanding the parcel over
Downloadcollecting a parcel, then opening the box

If the contents are not the point of the test, a look at the outside may be enough.

TELL A FRIEND

Handing a parcel over, and opening the one you collect.

OFTEN MIXED UP WITH Files, imports and exports. The general lesson says what to check about files. This lesson shows the Playwright calls.

Sources & standards — 4 sources
  1. Market practice

    Locator (Playwright documentation) ↗ — Microsoft (Playwright) · Reviewed 6 November 2026: selectOption, setChecked, setInputFiles and tap. See v45 source analysis for version scope and documented source ambiguities; no upstream run claimed.

    Reference for locator.setInputFiles, which sets the files of a file input from paths or in-memory buffers, resolves relative paths from the working directory and clears the selection with an empty array; also frameLocator for content inside an iframe. Vendor documentation for one tool. Practitioner or vendor guidance, not a standard. · Checked 2026-11-06

    Primary source opened and operative text inspected on 6 November 2026. Scope: selectOption, setChecked, setInputFiles and tap. Current live Playwright documentation reflects 1.65 where stated; explicit older examples retain their version. Source inspection is not an execution or compatibility-test claim. See the completed v45 Playwright analysis for source discrepancies and exact reading boundaries.

  2. Market practice

    Actions (Playwright documentation) ↗ — Microsoft (Playwright) · Reviewed 6 November 2026: Complete extracted primary article; examples inspected, not executed. See v45 source analysis for version scope and documented source ambiguities; no upstream run claimed.

    Says locator.setInputFiles takes a path, an array of paths, an empty array to clear, or an in-memory buffer, and that the file chooser route is for inputs created on the fly. Vendor documentation for one tool. Practitioner or vendor guidance, not a standard. · Checked 2026-11-06

    Primary source opened and operative text inspected on 6 November 2026. Scope: Complete extracted primary article; examples inspected, not executed. Current live Playwright documentation reflects 1.65 where stated; explicit older examples retain their version. Source inspection is not an execution or compatibility-test claim. See the completed v45 Playwright analysis for source discrepancies and exact reading boundaries.

  3. Market practice

    FileChooser (Playwright documentation) ↗ — Microsoft (Playwright) · Listen for the filechooser event before the click that opens the chooser, then call fileChooser.setFiles (search excerpt, page not opened)

    Shows listening for the filechooser event before the click that opens the chooser, then passing files with fileChooser.setFiles. Vendor documentation for one tool. Practitioner or vendor guidance, not a standard. · Checked 2026-10-18

    Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.

  4. Market practice

    Downloads (Playwright documentation) ↗ — Microsoft (Playwright) · Wait for the download event before the click; suggestedFilename and saveAs on the download; saveAs waits for the download to finish; downloaded files are deleted when the browser context closes (search excerpt, page not opened)

    Download event ordering and saveAs. The context owns temporary downloaded files and deletes those temporary files on context close; a separately saved copy has its own filesystem lifetime. Verifying a suggested filename does not verify exported contents. Existing October source-search provenance remains limited; operative behavior is cross-checked through the actual Input/Downloads-linked API scope in the v45 audit. · Checked 2026-10-18

    Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.

PRACTISE AND KEEP

Sources for this topic — 5 sources
  1. Market practice

    Locator (Playwright documentation) ↗ — Microsoft (Playwright) · Reviewed 6 November 2026: selectOption, setChecked, setInputFiles and tap. See v45 source analysis for version scope and documented source ambiguities; no upstream run claimed.

    Reference for locator.setInputFiles, which sets the files of a file input from paths or in-memory buffers, resolves relative paths from the working directory and clears the selection with an empty array; also frameLocator for content inside an iframe. Vendor documentation for one tool. Practitioner or vendor guidance, not a standard. · Checked 2026-11-06

    Primary source opened and operative text inspected on 6 November 2026. Scope: selectOption, setChecked, setInputFiles and tap. Current live Playwright documentation reflects 1.65 where stated; explicit older examples retain their version. Source inspection is not an execution or compatibility-test claim. See the completed v45 Playwright analysis for source discrepancies and exact reading boundaries.

  2. Market practice

    Actions (Playwright documentation) ↗ — Microsoft (Playwright) · Reviewed 6 November 2026: Complete extracted primary article; examples inspected, not executed. See v45 source analysis for version scope and documented source ambiguities; no upstream run claimed.

    Says locator.setInputFiles takes a path, an array of paths, an empty array to clear, or an in-memory buffer, and that the file chooser route is for inputs created on the fly. Vendor documentation for one tool. Practitioner or vendor guidance, not a standard. · Checked 2026-11-06

    Primary source opened and operative text inspected on 6 November 2026. Scope: Complete extracted primary article; examples inspected, not executed. Current live Playwright documentation reflects 1.65 where stated; explicit older examples retain their version. Source inspection is not an execution or compatibility-test claim. See the completed v45 Playwright analysis for source discrepancies and exact reading boundaries.

  3. Market practice

    FileChooser (Playwright documentation) ↗ — Microsoft (Playwright) · Listen for the filechooser event before the click that opens the chooser, then call fileChooser.setFiles (search excerpt, page not opened)

    Shows listening for the filechooser event before the click that opens the chooser, then passing files with fileChooser.setFiles. Vendor documentation for one tool. Practitioner or vendor guidance, not a standard. · Checked 2026-10-18

    Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.

  4. Market practice

    Downloads (Playwright documentation) ↗ — Microsoft (Playwright) · Wait for the download event before the click; suggestedFilename and saveAs on the download; saveAs waits for the download to finish; downloaded files are deleted when the browser context closes (search excerpt, page not opened)

    Download event ordering and saveAs. The context owns temporary downloaded files and deletes those temporary files on context close; a separately saved copy has its own filesystem lifetime. Verifying a suggested filename does not verify exported contents. Existing October source-search provenance remains limited; operative behavior is cross-checked through the actual Input/Downloads-linked API scope in the v45 audit. · Checked 2026-10-18

    Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.

  5. Market practice

    Download (Playwright documentation) ↗ — Microsoft (Playwright) · Describes download.suggestedFilename(), download.saveAs(path), download.path() and download.failure(), which returns an error text or null and waits for the download to finish (search excerpt, page not opened)

    Describes download.suggestedFilename(), download.saveAs(path), download.path() and download.failure(), which returns an error text or null and waits for the download to finish. Vendor documentation for one tool. Practitioner or vendor guidance, not a standard. · Checked 2026-10-18

    Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.

Deepest material on this page: L4 — Standards & sources. Where a topic stops short of implementation depth, that is a deliberate coverage decision, not an oversight — see coverage.