Practice Widgets Upload & Download
setInputFiles · download
Widget practice · Files

Upload & Download

Playwright drives the standard HTML file input via locator.setInputFiles(...) — no OS dialog is opened. Downloads are caught with page.waitForEvent('download') + download.saveAs(). Native OS upload dialogs from custom widgets are out of scope; this page sticks to the standard, supported flow.

① Single file upload

Standard <input type="file">. Playwright sets the file directly on the input.

id=single-upload data-testid=single-upload · single-preview type=file (single)

② Multiple file upload

multiple attribute lets you select several. Playwright passes an array to setInputFiles.

id=multi-upload attr=multiple

③ Drag-drop zone (still uses setInputFiles)

The visual is a div, but the hidden input behind it is what Playwright targets. Users see a drop zone; tests target the input.

Drop files here or use the hidden input #dropzone-input for tests.
id=dropzone-input (hidden) · dropzone (visual) data-testid=dropzone-input

④ Downloads

Anchor with download attribute serves a generated Blob. Capture via page.waitForEvent('download').

Download static file
data-testid=download-text · download-json · download-static API=page.waitForEvent('download') · download.saveAs(path)
No file action yet.