grafana/k6 · error
mouse down
Error message
mouse down: %w
What it means
Low-level failure of the CDP Input.dispatchMouseEvent(MousePressed) command itself, carrying the button, modifiers, and click count. Fires when the DevTools protocol executor rejects the event — session closed, target gone, or browser-side input error — not because of element state.
Solutions
- Verify the CDP session and target are alive before dispatching
- Check the button value is a valid input.MouseButton constant
- Avoid dispatching input events after page/target close
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at internal/js/modules/k6/browser/common/mouse.go:92 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/f90c43eb4ea511df.
Report an issue: GitHub.
Appendix: source
Thrown at internal/js/modules/k6/browser/common/mouse.go:92
return nil
}
// Down will trigger a MouseDown event in the browser.
func (m *Mouse) Down(opts *MouseDownUpOptions) error {
if err := m.down(opts); err != nil {
return fmt.Errorf("pressing the mouse button on x:%f y:%f: %w", m.x, m.y, err)
}
return nil
}
func (m *Mouse) down(opts *MouseDownUpOptions) error {
m.button = input.MouseButton(opts.Button)
action := input.DispatchMouseEvent(input.MousePressed, 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 down: %w", err)
}
return nil
}
// Up will trigger a MouseUp event in the browser.
func (m *Mouse) Up(opts *MouseDownUpOptions) error {
if err := m.up(opts); err != nil {
return fmt.Errorf("releasing the mouse button on x:%f y:%f: %w", m.x, m.y, err)
}
return nil
}
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)View on GitHub (pinned to 01ffac6f24)