Skip to content

How to Handle File Upload in Selenium and Playwright

Practice file upload automation — single file, multiple files, drag and drop, type restrictions, size validation, hidden inputs, and upload progress in Playwright, Selenium & Cypress.

Intermediate15 min8 scenarios14 test cases

Interactive Scenarios

S01Scenario 1: Upload a Single File
No file selected
S02Scenario 2: Upload Multiple Files
No files selected
S03Scenario 3: Assert File Name After Selection (Medium)
🗂️No file chosen

Inner <span> has no data-testid. Target via [data-testid="fu-filename-display"] span[role="status"].

Filename not asserted
S04Scenario 4: Drag & Drop Upload Zone (Hard)
📂Drag & drop a file hereor click to browse · hidden input inside zone

Automation tip: target [data-testid="fu-drop-input"] inside the zone and use setInputFiles().

No file dropped
S05Scenario 5: File Type Restriction (Medium)

Input has accept="image/*". Upload a non-image file to trigger the error.

Type not validated
S06Scenario 6: File Size Validation (Hard)

Max size: 2 MB. Error paragraph has no data-testid — locate via .error-msg class inside the panel.

Size not validated
S07Scenario 7: Custom Button Triggers Hidden Input (Challenge)CHALLENGE

The styled button triggers a visually hidden input[type="file"]. The input has no data-testid. Target via: [data-testid="fu-hidden-zone"] input[type="file"].

Hidden input not targeted
S08Scenario 8: Upload Progress Bar (Challenge)CHALLENGE

Progress bar has no data-testid. Use getByRole('progressbar') to locate it.

Progress not tracked