From dcf4e4e0542bd94d33d5ff8ac75d2101c220206f Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Wed, 12 Jun 2024 22:20:18 +0200 Subject: [PATCH] feat: allow folder uploads (#31165) --- docs/src/api/class-elementhandle.md | 1 + docs/src/api/class-locator.md | 1 + docs/src/api/class-page.md | 1 + .../src/client/elementHandle.ts | 55 +++++++++++--- .../playwright-core/src/protocol/validator.ts | 18 +++-- .../dispatchers/browserContextDispatcher.ts | 15 +++- .../dispatchers/writableStreamDispatcher.ts | 18 +++-- packages/playwright-core/src/server/dom.ts | 26 +++++-- .../src/server/fileUploadUtils.ts | 11 ++- .../src/server/webkit/wkPage.ts | 12 +-- packages/playwright-core/types/types.d.ts | 9 ++- packages/protocol/src/channels.ts | 28 +++++-- packages/protocol/src/protocol.yml | 21 +++++- tests/assets/input/folderupload.html | 12 +++ tests/electron/playwright.config.ts | 2 + tests/page/page-set-input-files.spec.ts | 73 ++++++++++++++++++- tests/webview2/playwright.config.ts | 1 + 17 files changed, 245 insertions(+), 59 deletions(-) create mode 100644 tests/assets/input/folderupload.html diff --git a/docs/src/api/class-elementhandle.md b/docs/src/api/class-elementhandle.md index dbf99eb3a2..24b8bb2b6f 100644 --- a/docs/src/api/class-elementhandle.md +++ b/docs/src/api/class-elementhandle.md @@ -953,6 +953,7 @@ When all steps combined have not finished during the specified [`option: timeout Sets the value of the file input to these file paths or files. If some of the `filePaths` are relative paths, then they are resolved relative to the current working directory. For empty array, clears the selected files. +For inputs with a `[webkitdirectory]` attribute, only a single directory path is supported. This method expects [ElementHandle] to point to an [input element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input). However, if the element is inside the `