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
Copy file name to clipboardExpand all lines: apps/site/docs/en/automate-with-scripts-in-yaml.mdx
+38Lines changed: 38 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -454,6 +454,7 @@ tasks:
454
454
deepThink: <boolean> # Optional, whether to use deepThink to precisely locate the element. Defaults to False.
455
455
xpath: <xpath> # Optional, the xpath of the target element for the operation. If provided, Midscene will prioritize this xpath to find the element before using the cache and the AI model. Defaults to empty.
456
456
cacheable: <boolean> # Optional, whether to cache the result of this API call when the [caching feature](./caching.mdx) is enabled. Defaults to True.
457
+
fileChooserAccept: <path> | [<path1>, <path2>] # Optional, file path(s) to upload when the tap triggers a file chooser; only available on web
457
458
458
459
# Hover over an element described by a prompt.
459
460
- aiHover: <prompt>
@@ -519,6 +520,43 @@ tasks:
519
520
# ...
520
521
```
521
522
523
+
#### Upload Files With `aiTap`
524
+
525
+
When clicking a button opens a file chooser, you can set `fileChooserAccept` directly on the `aiTap` step. It accepts either a single path or an array of paths.
526
+
527
+
```yaml
528
+
tasks:
529
+
- name: upload single file
530
+
flow:
531
+
- aiTap: Choose file button
532
+
fileChooserAccept: ./fixtures/document.pdf
533
+
534
+
- name: upload multiple files
535
+
flow:
536
+
- aiTap: Upload images button
537
+
fileChooserAccept:
538
+
- ./fixtures/image1.jpg
539
+
- ./fixtures/image2.png
540
+
```
541
+
542
+
If you are already using a `locate` object for `prompt`, `images`, or other locate options, keep `fileChooserAccept` at the same level as `locate`. Do not nest it inside `locate` or inside the `aiTap` object:
543
+
544
+
```yaml
545
+
tasks:
546
+
- name: upload file with locate
547
+
flow:
548
+
- aiTap:
549
+
locate:
550
+
prompt: Click the upload button
551
+
fileChooserAccept: ./fixtures/document.pdf
552
+
```
553
+
554
+
Notes:
555
+
556
+
- `fileChooserAccept`is only available for web pages (Playwright, Puppeteer).
557
+
- Relative paths are resolved from the current command working directory, not from the YAML file directory.
558
+
- If a file does not exist, the script throws before the tap is executed.
559
+
522
560
#### Prompting with images
523
561
524
562
For steps whose prompt accepts images, you can attach images to the prompt by setting the `images` field to an array of objects, each containing a `name` and a `url`. (see the [API reference](./api#prompting-with-images)), replace the string value with an object that contains:
0 commit comments