Merge pull request 'feat: add steps parameter to MouseMove' (#82) from feature/81-mousemove-steps into main
This commit was merged in pull request #82.
This commit is contained in:
@@ -27,8 +27,9 @@ type InteractiveBrowser interface {
|
|||||||
MouseDown(x, y float64, button string) error
|
MouseDown(x, y float64, button string) error
|
||||||
// MouseUp releases the mouse button at the given coordinates.
|
// MouseUp releases the mouse button at the given coordinates.
|
||||||
MouseUp(x, y float64, button string) error
|
MouseUp(x, y float64, button string) error
|
||||||
// MouseMove moves the mouse to the given coordinates.
|
// MouseMove moves the mouse to the given coordinates. An optional steps parameter
|
||||||
MouseMove(x, y float64) error
|
// controls how many intermediate mousemove events are generated (default 1).
|
||||||
|
MouseMove(x, y float64, steps ...int) error
|
||||||
// MouseWheel scrolls by the given delta.
|
// MouseWheel scrolls by the given delta.
|
||||||
MouseWheel(deltaX, deltaY float64) error
|
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})
|
return ib.page.Mouse().Up(playwright.MouseUpOptions{Button: btn})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ib *interactiveBrowser) MouseMove(x, y float64) error {
|
func (ib *interactiveBrowser) MouseMove(x, y float64, steps ...int) error {
|
||||||
return ib.page.Mouse().Move(x, y)
|
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 {
|
func (ib *interactiveBrowser) MouseWheel(deltaX, deltaY float64) error {
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ func (m mockInteractiveBrowser) URL() string { return
|
|||||||
func (m mockInteractiveBrowser) MouseClick(float64, float64, string) error { return nil }
|
func (m mockInteractiveBrowser) MouseClick(float64, float64, string) error { return nil }
|
||||||
func (m mockInteractiveBrowser) MouseDown(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) 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) MouseWheel(float64, float64) error { return nil }
|
||||||
func (m mockInteractiveBrowser) KeyboardType(string) error { return nil }
|
func (m mockInteractiveBrowser) KeyboardType(string) error { return nil }
|
||||||
func (m mockInteractiveBrowser) KeyboardPress(string) error { return nil }
|
func (m mockInteractiveBrowser) KeyboardPress(string) error { return nil }
|
||||||
|
|||||||
Reference in New Issue
Block a user