grafana/k6 · error

clicking on x: y

Error message

clicking on x:%f y:%f: %w

What it means

Wrapped failure from the internal Mouse.click sequence (move + down + up, with optional inter-click delay) at the given viewport coordinates. Fires when any of the underlying CDP Input.dispatchMouseEvent commands is rejected — commonly because the page/session was closed or the context was canceled mid-sequence.

Solutions

  1. Verify the page and browser session are still alive before clicking
  2. Ensure coordinates lie within the current viewport size
  3. Check for k6 iteration teardown canceling the context during the click
Defensive patterns

Strategy: try-catch

When it happens

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

Appendix: source

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

	button          input.MouseButton
}

// NewMouse creates a new mouse.
func NewMouse(ctx context.Context, s session, f *Frame, ts *TimeoutSettings, k *Keyboard) *Mouse {
	return &Mouse{
		ctx:             ctx,
		session:         s,
		frame:           f,
		timeoutSettings: ts,
		keyboard:        k,
		button:          input.None,
	}
}

// Click will trigger a series of MouseMove, MouseDown and MouseUp events in the browser.
func (m *Mouse) Click(x float64, y float64, opts *MouseClickOptions) error {
	if err := m.click(x, y, opts); err != nil {
		return fmt.Errorf("clicking on x:%f y:%f: %w", x, y, err)
	}
	return nil
}

func (m *Mouse) click(x float64, y float64, opts *MouseClickOptions) error {
	mouseDownUpOpts := opts.ToMouseDownUpOptions()
	if err := m.move(x, y, NewMouseMoveOptions()); err != nil {
		return err
	}
	for i := 0; i < int(mouseDownUpOpts.ClickCount); i++ {
		if err := m.down(mouseDownUpOpts); err != nil {
			return err
		}
		if opts.Delay != 0 {
			t := time.NewTimer(time.Duration(opts.Delay) * time.Millisecond)
			select {
			case <-m.ctx.Done():
				t.Stop()

View on GitHub (pinned to 01ffac6f24)