Add steps parameter to MouseMove for smooth drag gestures
#81
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
MouseMove(x, y float64)currently callsib.page.Mouse().Move(x, y)without passingMouseMoveOptions{Steps}. Playwright'sStepsparameter defaults to 1, meaning only oneInput.dispatchMouseEventCDP call is generated perMouseMove()invocation.This is a problem for slider captchas (e.g. DataDome) and other drag-based interactions where the target JavaScript listens for a stream of
mousemoveevents during a drag. When the mouse jumps from position A to position B in a single event (no intermediate positions), the JS detects it as bot-like behavior and rejects the interaction.How Playwright's
StepsWorksFrom Playwright's Mouse.move() docs:
When
Steps: 5is passed, Playwright interpolates 5 intermediate positions and dispatches 5 separateInput.dispatchMouseEventCDP calls, making the movement appear smooth and human-like.The
playwright-gobindings support this viaMouseMoveOptions:See also:
playwright-go/tests/input_test.gowhich testsSteps: playwright.Int(5).Proposed Fix
1. Add
stepsvariadic parameter toMouseMoveChange the signature to accept an optional steps count (backward compatible):
The
InteractiveBrowserinterface would also need updating:This is fully backward compatible — existing callers that pass no
stepsargument get the same behavior as today.2. (Optional) Add
Dragconvenience methodA higher-level method that does MouseDown → MouseMove (with steps) → MouseUp:
This would be convenient but is less critical since callers can compose the three calls themselves.
Impact
This fix is trivial (1-2 lines changed) but enables smooth drag gestures in the mort captcha proxy and browser proxy. Without it, mort has to implement manual position interpolation on its side as a workaround.
Starting work. Will add the
steps ...intvariadic parameter toMouseMovein the interface and implementation, and update the mock. Skipping the optionalDragconvenience method for now since callers can compose the three calls themselves.Done. PR #82 merged.
MouseMovenow accepts an optionalsteps ...intparameter for smooth intermediate mousemove events.