You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implements the `upload` action in `BrowserSession` to allow uploading files through the Puppeteer-controlled browser.
- Handles standard file inputs using `elementHandle.uploadFile()`.
- Supports hidden file inputs by temporarily making them visible.
- Includes a fallback mechanism using `page.waitForFileChooser()`.
- Adds `waitForNetworkIdle` and `checkForUploadSuccessIndicators` heuristics to help determine upload completion.
- Includes unit tests (`BrowserSession.upload.test.ts`) and necessary fixtures (`file-upload-test.html`, `test-upload-file.txt`).
- Updates shared types (`ExtensionMessage.ts`) and tool documentation (`browser-action.ts`) to include the new action and clarify the absolute path requirement for `filepath`.
Description: Request to interact with a Puppeteer-controlled browser. Every action, except \`close\`, will be responded to with a screenshot of the browser's current state, along with any new console logs. You may only perform one browser action per message, and wait for the user's response including a screenshot and logs to determine the next action.
9
9
- The sequence of actions **must always start with** launching the browser at a URL, and **must always end with** closing the browser. If you need to visit a new URL that is not possible to navigate to from the current webpage, you must first close the browser, then launch again at the new URL.
10
10
- While the browser is active, only the \`browser_action\` tool can be used. No other tools should be called during this time. You may proceed to use other tools only after closing the browser. For example if you run into an error and need to fix a file, you must close the browser, then use other tools to make the necessary changes, then re-launch the browser to verify the result.
11
+
- **IMPORTANT: NEVER click on buttons that would open a system file dialog.** Instead, use the \`upload\` action directly with the file input element's selector and the desired file path.
11
12
- The browser window has a resolution of **${args.browserViewportSize}** pixels. When performing any click actions, ensure the coordinates are within this resolution range.
12
13
- Before clicking on any elements such as icons, links, or buttons, you must consult the provided screenshot of the page to determine the coordinates of the element. The click should be targeted at the **center of the element**, not on its edges.
13
14
Parameters:
@@ -18,13 +19,15 @@ Parameters:
18
19
* click: Click at a specific x,y coordinate.
19
20
- Use with the \`coordinate\` parameter to specify the location.
20
21
- Always click in the center of an element (icon, button, link, etc.) based on coordinates derived from a screenshot.
22
+
- **DO NOT click on buttons labeled "Upload", "Choose File", "Browse", or similar that would open system file dialogs.** Use the \`upload\` action instead.
21
23
* type: Type a string of text on the keyboard. You might use this after clicking on a text field to input text.
22
24
- Use with the \`text\` parameter to provide the string to type.
23
25
* scroll_down: Scroll down the page by one page height.
24
26
* scroll_up: Scroll up the page by one page height.
25
-
* upload: Upload a file to a file input element on the page.
26
-
- Use with the \`selector\` parameter to specify the CSS selector for the file input element.
27
+
* upload: **UPLOAD FILES DIRECTLY WITH THIS ACTION - DO NOT CLICK ON UPLOAD BUTTONS.** This action uploads a file to a file input element on the page by directly setting its value, bypassing any system file dialogs.
28
+
- Use with the \`selector\` parameter to specify the CSS selector for the file input element (typically \`input[type="file"]\`).
27
29
- Use with the \`filepath\` parameter to specify the path to the file to upload.
30
+
- **IMPORTANT:** Always use this action instead of clicking on buttons that would open system file dialogs.
28
31
* close: Close the Puppeteer-controlled browser instance. This **must always be the final browser action**.
29
32
- Example: \`<action>close</action>\`
30
33
- url: (optional) Use this for providing the URL for the \`launch\` action.
@@ -35,8 +38,8 @@ Parameters:
35
38
* Example: <text>Hello, world!</text>
36
39
- selector: (optional) The CSS selector for the file input element for the \`upload\` action.
// Intercept file chooser triggered by click and throw an error
355
+
thrownewError(
356
+
"Clicking this element opened a file selection dialog. You MUST use the 'upload' action with a valid CSS selector for the file input element and the file path instead of clicking.",
0 commit comments