Skip to content

feat: support uploading multiple files with upload_file#2257

Open
serhiizghama wants to merge 3 commits into
ChromeDevTools:mainfrom
serhiizghama:feat/upload-file-multiple
Open

feat: support uploading multiple files with upload_file#2257
serhiizghama wants to merge 3 commits into
ChromeDevTools:mainfrom
serhiizghama:feat/upload-file-multiple

Conversation

@serhiizghama

Copy link
Copy Markdown
Contributor

Closes #1217. upload_file only took a single path, so there was no way to fill an input[type=file][multiple] in one call.

filePath now also accepts an array of paths. A plain string still works for the single-file case, so existing callers don't change — Puppeteer's uploadFile/fileChooser.accept already take multiple paths, so the handler just normalizes to an array and forwards them.

The union (string | string[]) needed a bit of plumbing: the CLI generator threw on non-scalar types, the docs generator rendered it as unknown, and the telemetry transformer didn't know ZodUnion. The CLI exposes the single-value form (it can't pass arrays anyway), the docs show string or array, and metrics count it like an array with scalars normalized to one. Regenerated artifacts are included.

Added a test that uploads two files to a multi-file input and asserts both land, plus telemetry coverage for the union. npm run typecheck, lint/prettier, and the upload + transformation tests all pass.

Allow filePath to be an array so a single call can populate inputs with
the multiple attribute. A string is still accepted for the common
single-file case, so existing callers are unaffected.
The CLI/docs generators and the telemetry transformer only handled
scalar and array params, so the upload_file union tripped them. Map the
union to its string form for the CLI, render both members in the docs,
and count it as an array in metrics (scalars normalized to one). Includes
the regenerated artifacts.
@itxaiohanglover

Copy link
Copy Markdown

Good feature addition! Supporting array filePath for multiple file uploads is useful. The CLI schema update to handle string | string[] union types is a nice touch — exposing the single-value form for CLI is pragmatic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support multi-file uploads for existing-session mode

2 participants