Playwright locator.drop() simulates external drag-and-drop
Introduced 2026-05-11 · score 0.98
HOW TO USE IT
When testing an element that accepts external file or clipboard-like drops, call `locator.drop()` with a `files` payload, a MIME-type-to-string `data` map, or both.
await page.locator('<dropzone-selector>').drop({ files: { name: 'note.txt', mimeType: 'text/plain', buffer: Buffer.from('hello') } });await page.locator('<dropzone-selector>').drop({ data: { 'text/plain': 'hello world', 'text/uri-list': 'https://example.com' } });WHY THIS HELPS
Test a page's file upload zone or other drag-and-drop target.
REQUIREMENTS AND LIMITATIONS
- Version: v1.60.0
- payload.files: File paths or in-memory buffers; file objects use `name` (file name), `mimeType` (file type), and `buffer` (file content).
- payload.data: MIME-type-to-string map for clipboard-like content; may be used with `files` or by itself.
- options.position: Target point relative to the element’s padding-box top-left; defaults to a visible point.
- options.timeout: Maximum time in milliseconds; defaults to 0 (no timeout).
- Prerequisite: `locator.drop()` was added in Playwright v1.60.
- Works cross-browser.
FIRST-PARTY EVIDENCE
- https://github.com/microsoft/playwright/releases/tag/v1.60.0
- https://playwright.dev/docs/api/class-locator#locator-drop
Check the installed version and the source before using it. Entry JSON