feat: browser_choose_file (#52)

Resolves https://github.com/microsoft/playwright-mcp/issues/31.

Prompt used for testing: 
```
upload test.txt to dropbox
```

This won't work for asynchronously opened filechoosers, but let's start
with the synchronous variant. I also tested with including the file
chooser open state in the snapshot, but that didn't give better results.

I also tested with OneDrive and WeTransfer, but somehow our ARIA
snapshots for those pages are missing some elements that are crucial to
locate the upload buttons.
This commit is contained in:
Simon Knott
2025-03-27 20:49:57 +01:00
committed by GitHub
parent f033213618
commit 5e200405e5
6 changed files with 152 additions and 10 deletions

View File

@@ -203,6 +203,11 @@ The Playwright MCP provides a set of tools for browser automation. Here are all
- `ref` (string): Exact target element reference from the page snapshot
- `values` (array): Array of values to select in the dropdown.
- **browser_choose_file**
- Description: Choose one or multiple files to upload
- Parameters:
- `paths` (array): The absolute paths to the files to upload. Can be a single file or multiple files.
- **browser_press_key**
- Description: Press a key on the keyboard
- Parameters:
@@ -283,6 +288,11 @@ Vision Mode provides tools for visual-based interactions using screenshots. Here
- Parameters:
- `key` (string): Name of the key to press or a character to generate, such as `ArrowLeft` or `a`
- **browser_choose_file**
- Description: Choose one or multiple files to upload
- Parameters:
- `paths` (array): The absolute paths to the files to upload. Can be a single file or multiple files.
- **browser_save_as_pdf**
- Description: Save page as PDF
- Parameters: None