Add MouseDown/MouseUp methods to InteractiveBrowser interface #79

Closed
opened 2026-02-28 15:24:27 +00:00 by Claude · 3 comments
Collaborator

Problem

The InteractiveBrowser interface currently has MouseClick (which does mousedown+mouseup at the same position), MouseMove, and MouseWheel. However, there's no way to perform a drag operation, which requires:

  1. MouseDown at position A
  2. MouseMove to position B
  3. MouseUp at position B

This is needed for slider captchas (e.g., DataDome's GeeTest slider used by NYT) where the user must drag a slider handle from left to right.

Proposed Change

Add two new methods to InteractiveBrowser:

// MouseDown presses the mouse button at the given coordinates without releasing.
MouseDown(x, y float64, button string) error
// MouseUp releases the mouse button at the given coordinates.
MouseUp(x, y float64, button string) error

Implementation would use Playwright's existing page.Mouse().Down() and page.Mouse().Up():

func (ib *interactiveBrowser) MouseDown(x, y float64, button string) error {
    if err := ib.page.Mouse().Move(x, y); err != nil {
        return err
    }
    var btn *playwright.MouseButton
    switch button {
    case "right":
        btn = playwright.MouseButtonRight
    case "middle":
        btn = playwright.MouseButtonMiddle
    default:
        btn = playwright.MouseButtonLeft
    }
    return ib.page.Mouse().Down(playwright.MouseDownOptions{Button: btn})
}

func (ib *interactiveBrowser) MouseUp(x, y float64, button string) error {
    if err := ib.page.Mouse().Move(x, y); err != nil {
        return err
    }
    var btn *playwright.MouseButton
    switch button {
    case "right":
        btn = playwright.MouseButtonRight
    case "middle":
        btn = playwright.MouseButtonMiddle
    default:
        btn = playwright.MouseButtonLeft
    }
    return ib.page.Mouse().Up(playwright.MouseUpOptions{Button: btn})
}

Context

Mort's captcha proxy and browser proxy use InteractiveBrowser for remote browser control. Without drag support, users cannot solve slider captchas through the proxy. The mort-side changes (JS client + Go handler) are ready and will use an optional interface check so they work automatically once this is implemented.

## Problem The `InteractiveBrowser` interface currently has `MouseClick` (which does mousedown+mouseup at the same position), `MouseMove`, and `MouseWheel`. However, there's no way to perform a **drag** operation, which requires: 1. `MouseDown` at position A 2. `MouseMove` to position B 3. `MouseUp` at position B This is needed for slider captchas (e.g., DataDome's GeeTest slider used by NYT) where the user must drag a slider handle from left to right. ## Proposed Change Add two new methods to `InteractiveBrowser`: ```go // MouseDown presses the mouse button at the given coordinates without releasing. MouseDown(x, y float64, button string) error // MouseUp releases the mouse button at the given coordinates. MouseUp(x, y float64, button string) error ``` Implementation would use Playwright's existing `page.Mouse().Down()` and `page.Mouse().Up()`: ```go func (ib *interactiveBrowser) MouseDown(x, y float64, button string) error { if err := ib.page.Mouse().Move(x, y); err != nil { return err } var btn *playwright.MouseButton switch button { case "right": btn = playwright.MouseButtonRight case "middle": btn = playwright.MouseButtonMiddle default: btn = playwright.MouseButtonLeft } return ib.page.Mouse().Down(playwright.MouseDownOptions{Button: btn}) } func (ib *interactiveBrowser) MouseUp(x, y float64, button string) error { if err := ib.page.Mouse().Move(x, y); err != nil { return err } var btn *playwright.MouseButton switch button { case "right": btn = playwright.MouseButtonRight case "middle": btn = playwright.MouseButtonMiddle default: btn = playwright.MouseButtonLeft } return ib.page.Mouse().Up(playwright.MouseUpOptions{Button: btn}) } ``` ## Context Mort's captcha proxy and browser proxy use `InteractiveBrowser` for remote browser control. Without drag support, users cannot solve slider captchas through the proxy. The mort-side changes (JS client + Go handler) are ready and will use an optional interface check so they work automatically once this is implemented.
Author
Collaborator

Starting work on this. Plan: add MouseDown and MouseUp to the InteractiveBrowser interface and implement them on interactiveBrowser, following the pattern from the issue description. Will also update the mock in promote_test.go.

Starting work on this. Plan: add `MouseDown` and `MouseUp` to the `InteractiveBrowser` interface and implement them on `interactiveBrowser`, following the pattern from the issue description. Will also update the mock in `promote_test.go`.
Author
Collaborator

Done. PR #80 has been merged. Added MouseDown and MouseUp to the InteractiveBrowser interface and implementation.

Done. PR #80 has been merged. Added `MouseDown` and `MouseUp` to the `InteractiveBrowser` interface and implementation.
Author
Collaborator

Resolved — MouseDown and MouseUp are now part of InteractiveBrowser. Updated mort in PR steve/mort#862 to use them directly for drag gesture support (slider captchas).

Resolved — `MouseDown` and `MouseUp` are now part of `InteractiveBrowser`. Updated mort in PR steve/mort#862 to use them directly for drag gesture support (slider captchas).
Sign in to join this conversation.