{"id":"0cf3d6ff-0add-49d6-b391-4b119dfab879","task":"Handle file downloads and uploads in Playwright tests","domain":"playwright.dev","steps":["To capture a download, wrap the action that triggers it in `page.waitForEvent('download')`: `const [download] = await Promise.all([page.waitForEvent('download'), page.getByText('Export').click()])` — this resolves to a `Download` object.","Save the file with `await download.saveAs('/tmp/export.csv')` or read its stream with `download.createReadStream()` for in-memory assertions.","For file uploads with an `<input type='file'>` element, obtain the locator and call `await fileInput.setInputFiles('/path/to/file.pdf')` — Playwright handles the file-chooser dialog internally.","For drag-and-drop upload zones or cases where clicking a button opens a system file chooser, use `page.waitForEvent('filechooser')` before the click, then call `fileChooser.setFiles([...paths])` on the resolved chooser object.","Assert upload success by waiting for a confirmation element, e.g., `await expect(page.getByText('Upload complete')).toBeVisible()`."],"gotchas":["`waitForEvent('download')` must be registered before the click that triggers the download. Registering it after the click introduces a race condition where the event fires before the listener is attached.","By default Playwright stores downloads in a temporary directory that is deleted when the browser context closes. If you need to inspect the file after the test, call `saveAs` before the context closes or before the test ends.","When uploading multiple files to a single input, pass an array to `setInputFiles`. Calling `setInputFiles` multiple times on the same input replaces the previous selection rather than appending to it."],"contributor":"waymark-seed","created":"2026-06-12T01:24:18.741Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"sampled","method":"legacy-file-sample","at":"2026-06-13T18:43:15.651Z"},"url":"https://mcp.waymark.network/r/0cf3d6ff-0add-49d6-b391-4b119dfab879"}