Skip to content

Add browse upload command for file uploads#1906

Open
derekmeegan wants to merge 1 commit intomainfrom
derek/add_file_upload
Open

Add browse upload command for file uploads#1906
derekmeegan wants to merge 1 commit intomainfrom
derek/add_file_upload

Conversation

@derekmeegan
Copy link
Copy Markdown
Contributor

@derekmeegan derekmeegan commented Mar 29, 2026

Summary

  • Adds browse upload <selector> <files...> command to upload files to <input type="file"> elements
  • Uses Understudy's setInputFiles under the hood, which handles both local (CDP DOM.setFileInputFiles) and remote/Browserbase (base64 payload injection) paths automatically
  • Supports ref-based selectors from browse snapshot (e.g., browse upload @0-5 ./doc.pdf)
  • Supports multiple files: browse upload @0-5 ./a.png ./b.png

Usage

browse upload <selector> <file>            # single file
browse upload @0-5 ./document.pdf          # using ref from snapshot
browse upload @0-5 ./a.png ./b.png         # multiple files

Test plan

  • Test single file upload on a local page with <input type="file">
  • Test multiple file upload
  • Test with ref-based selector from snapshot
  • Test on remote Browserbase session (base64 injection path)

🤖 Generated with Claude Code

Adds `browse upload <selector> <files...>` to upload files to
<input type="file"> elements. Uses Understudy's setInputFiles which
handles both local (DOM.setFileInputFiles) and remote/Browserbase
(base64 payload injection) paths. Supports single files, multiple
files, and ref-based selectors from snapshot.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 29, 2026

🦋 Changeset detected

Latest commit: 25e6ea1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 0 packages

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.
Architecture diagram
sequenceDiagram
    participant User
    participant CLI as CLI (index.ts)
    participant Locator as DeepLocator / Page
    participant Understudy as Understudy (Service Layer)
    participant Browser as Browser (Local/Remote)

    Note over User,Browser: NEW: File Upload Flow

    User->>CLI: browse upload <selector> <files...>
    
    CLI->>CLI: resolveSelector(selector)
    Note right of CLI: Handles @ref (snapshot) or CSS selectors
    
    CLI->>Locator: NEW: setInputFiles(files)
    
    Locator->>Understudy: setInputFiles(resolvedSelector, filePaths)
    
    alt Local Session
        Understudy->>Browser: CDP: DOM.setFileInputFiles
        Note right of Browser: Uses local file paths directly
    else Remote / Browserbase Session
        Understudy->>Understudy: Read local files & encode to Base64
        Understudy->>Browser: Inject Base64 payload via Protocol
    end
    
    Browser-->>Understudy: Success/Failure
    Understudy-->>Locator: Result
    Locator-->>CLI: { uploaded: true, files }
    
    alt Success
        CLI-->>User: Output JSON/Text result
    else Error
        CLI-->>User: console.error + process.exit(1)
    end
Loading

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.

1 participant