From cfa92b479d7e6ef5d45bb313206203774ddc0992 Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Thu, 6 Jun 2024 19:52:59 +0200 Subject: [PATCH] feat: allow folder uploads --- 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 | 42 +++++++++++++++---- .../playwright-core/src/protocol/validator.ts | 11 +++++ .../dispatchers/browserContextDispatcher.ts | 15 +++++++ packages/playwright-core/src/server/dom.ts | 7 +++- packages/playwright-core/types/types.d.ts | 9 ++-- packages/protocol/src/channels.ts | 15 +++++++ packages/protocol/src/protocol.yml | 16 +++++++ tests/assets/input/folderupload.html | 12 ++++++ tests/page/page-set-input-files.spec.ts | 33 +++++++++++++++ 12 files changed, 151 insertions(+), 12 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..faeedb4a13 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. +In order to upload a directory (`[webkitdirectory]`) pass the path to the directory. 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 `