feat: add steps parameter to MouseMove #82

Merged
Claude merged 1 commits from feature/81-mousemove-steps into main 2026-02-28 16:23:50 +00:00
2 changed files with 10 additions and 5 deletions

View File

@@ -27,8 +27,9 @@ type InteractiveBrowser interface {
MouseDown(x, y float64, button string) error
// MouseUp releases the mouse button at the given coordinates.
MouseUp(x, y float64, button string) error
// MouseMove moves the mouse to the given coordinates.
MouseMove(x, y float64) error
// MouseMove moves the mouse to the given coordinates. An optional steps parameter
// controls how many intermediate mousemove events are generated (default 1).
MouseMove(x, y float64, steps ...int) error
// MouseWheel scrolls by the given delta.
MouseWheel(deltaX, deltaY float64) error
@@ -192,8 +193,12 @@ func (ib *interactiveBrowser) MouseUp(x, y float64, button string) error {
return ib.page.Mouse().Up(playwright.MouseUpOptions{Button: btn})
}
func (ib *interactiveBrowser) MouseMove(x, y float64) error {
return ib.page.Mouse().Move(x, y)
func (ib *interactiveBrowser) MouseMove(x, y float64, steps ...int) error {
var opts playwright.MouseMoveOptions
if len(steps) > 0 && steps[0] > 1 {
opts.Steps = playwright.Int(steps[0])
}
return ib.page.Mouse().Move(x, y, opts)
}
func (ib *interactiveBrowser) MouseWheel(deltaX, deltaY float64) error {

View File

@@ -15,7 +15,7 @@ func (m mockInteractiveBrowser) URL() string { return
func (m mockInteractiveBrowser) MouseClick(float64, float64, string) error { return nil }
func (m mockInteractiveBrowser) MouseDown(float64, float64, string) error { return nil }
func (m mockInteractiveBrowser) MouseUp(float64, float64, string) error { return nil }
func (m mockInteractiveBrowser) MouseMove(float64, float64) error { return nil }
func (m mockInteractiveBrowser) MouseMove(float64, float64, ...int) error { return nil }
func (m mockInteractiveBrowser) MouseWheel(float64, float64) error { return nil }
func (m mockInteractiveBrowser) KeyboardType(string) error { return nil }
func (m mockInteractiveBrowser) KeyboardPress(string) error { return nil }