grafana/k6 · error

mouse move

Error message

mouse move: %w

What it means

Low-level failure while dispatching the interpolated MouseMoved events from the old to the new coordinates over opts.Steps increments. Fires when a CDP dispatch fails partway through the path — session closed, context canceled, or browser input rejection — after the internal x/y were already updated.

Solutions

  1. Ensure the session remains alive for the whole move sequence
  2. Use a sane Steps value (>=1) in MouseMoveOptions
  3. Treat the pointer position as updated-to-target even on failure, since state mutates first
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at internal/js/modules/k6/browser/common/mouse.go:138 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/d93b4fb59dbc5556. Report an issue: GitHub.

Appendix: source

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

	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)
		}
	}

	return nil
}

View on GitHub (pinned to 01ffac6f24)