Skip to content

Conversation

@NikhilGaddam
Copy link

@NikhilGaddam NikhilGaddam commented Feb 7, 2026

Fix file upload with relative paths

The upload command fails when relative file paths are passed because Playwright's setInputFiles expects absolute paths. This resolves relative paths to absolute before passing them to setInputFiles.

The previous approach of using CDP DOM.setFileInputFiles to avoid the native file dialog is unnecessary — Playwright's setInputFiles already bypasses the native dialog entirely. The CDP approach actually introduced a regression: cached CDP sessions become stale after page navigations, causing Target page, context or browser has been closed errors.

This keeps the fix minimal: just add path resolution while staying with Playwright's built-in API.

Fixes #192

@vercel
Copy link
Contributor

vercel bot commented Feb 7, 2026

@NikhilGaddam is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

@NikhilGaddam
Copy link
Author

Fixed the CSS selector issue! Now using DOM.describeNode to get the node ID directly from the element's remote object when dealing with refs. This completely avoids building CSS selectors from element attributes, so no more issues with special characters in IDs/names or the problematic input[type="file"] fallback that could match the wrong element.

Resolve relative file paths to absolute before passing to setInputFiles.
Playwright's setInputFiles already handles file uploads without opening
the native file dialog, so no CDP workaround is needed.

Fixes vercel-labs#192

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@NikhilGaddam NikhilGaddam force-pushed the fix-upload-native-dialog branch from 3668b4e to 7577da2 Compare February 8, 2026 04:47
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.

feat: File download and upload improvements

1 participant