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.
- Pick a small file
- Wait before the click
- Save the download
- Open and check
HOW THE PICTURE MAPS
| In the picture | In the software |
|---|---|
| Handing the parcel over | The upload |
| The slip you get | The page showing the file name |
| Collecting a parcel | The download |
| Opening the box | Reading 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.
| In the trick | What it stands for |
|---|---|
| Upload | handing the parcel over |
| Download | collecting 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
- 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.
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.
- 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.
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.
- 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)
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.
- 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)
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
- 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.
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.
- 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.
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.
- 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)
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.
- 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)
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.
- 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)
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.