grafana/k6 · error

moving the mouse pointer to x

Error message

moving the mouse pointer to x:%f y:%f: %w

What it means

Wrapped failure from Mouse.move while moving the pointer to the new coordinates. Fires when any CDP Input.dispatchMouseEvent(MouseMoved) step in the interpolated path fails — closed session, canceled context, or invalid target — not because of page content at the destination.

Solutions

  1. Verify the session is alive before moving
  2. Keep target coordinates within the viewport bounds
  3. Use fewer steps or smaller moves if the error occurs mid-sequence during teardown
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at internal/js/modules/k6/browser/common/mouse.go:121 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of grafana/k6@01ffac6f24 (2026-08-18). Data as JSON: /api/errors/870dcf02b8df51ef. Report an issue: GitHub.

Appendix: source

Thrown at internal/js/modules/k6/browser/common/mouse.go:121

}

func (m *Mouse) up(opts *MouseDownUpOptions) error {
	m.button = input.None
	action := input.DispatchMouseEvent(input.MouseReleased, m.x, m.y).
		WithButton(input.MouseButton(opts.Button)).
		WithModifiers(input.Modifier(m.keyboard.modifiers)).
		WithClickCount(opts.ClickCount)
	if err := action.Do(cdp.WithExecutor(m.ctx, m.session)); err != nil {
		return fmt.Errorf("mouse up: %w", err)
	}

	return nil
}

// Move will trigger a MouseMoved event in the browser.
func (m *Mouse) Move(x float64, y float64, opts *MouseMoveOptions) error {
	if err := m.move(x, y, opts); err != nil {
		return fmt.Errorf("moving the mouse pointer to x:%f y:%f: %w", x, y, err)
	}
	return nil
}

func (m *Mouse) move(x float64, y float64, opts *MouseMoveOptions) error {
	fromX := m.x
	fromY := m.y
	m.x = x
	m.y = y
	for i := int64(1); i <= opts.Steps; i++ {
		x := fromX + (m.x-fromX)*float64(i/opts.Steps)
		y := fromY + (m.y-fromY)*float64(i/opts.Steps)
		action := input.DispatchMouseEvent(input.MouseMoved, x, y).
			WithButton(m.button).
			WithModifiers(input.Modifier(m.keyboard.modifiers))
		if err := action.Do(cdp.WithExecutor(m.ctx, m.session)); err != nil {
			return fmt.Errorf("mouse move: %w", err)
		}

View on GitHub (pinned to 01ffac6f24)