From 7577da27a1165122866e98ec3ff543030109b99f Mon Sep 17 00:00:00 2001 From: Nikhil Gaddam Date: Sat, 7 Feb 2026 23:46:55 -0500 Subject: [PATCH] fix: resolve relative file paths in upload command 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 #192 Co-Authored-By: Claude Opus 4.6 --- src/actions.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/actions.ts b/src/actions.ts index c7a626c9..fcdb8230 100644 --- a/src/actions.ts +++ b/src/actions.ts @@ -826,14 +826,23 @@ async function handleUncheck(command: UncheckCommand, browser: BrowserManager): } async function handleUpload(command: UploadCommand, browser: BrowserManager): Promise { - const locator = browser.getLocator(command.selector); const files = Array.isArray(command.files) ? command.files : [command.files]; + try { - await locator.setInputFiles(files); + const absoluteFiles = files.map((file) => { + if (path.isAbsolute(file)) { + return file; + } + return path.resolve(process.cwd(), file); + }); + + const locator = browser.getLocator(command.selector); + await locator.setInputFiles(absoluteFiles); + + return successResponse(command.id, { uploaded: absoluteFiles }); } catch (error) { throw toAIFriendlyError(error, command.selector); } - return successResponse(command.id, { uploaded: files }); } async function handleDoubleClick(