Playwright

Upload a file

Medium70 pts
  • setInputFiles
  • File Upload
  • Buffer
Practice app · Document Vault

File upload and download, cookies, localStorage, sessionStorage and JavaScript execution.

Test URL
/lab/playwright-upload-a-file

Your starter code already declares TEST_URL — never hardcode a host.

Objective

Upload a file to a file input using setInputFiles and verify the selected filename.

Your Task

  1. 1Navigate to the file management vault at TEST_URL.
  2. 2Locate the single file upload input (#file-upload).
  3. 3Attach a file named 'test.csv' with MIME type 'text/csv' and content 'id,name\n1,QA'.
  4. 4Assert that the uploaded file list displays the file name 'test.csv' in the file name label (#file-name).

Validation Checks

  • File management vault is loaded at TEST_URL
  • File input (#file-upload) receives file attachment
  • File name (#file-name) displays 'test.csv'
  • At least 1 assertion passes

Playwright · Playwright Practice Track · Actions & inputs