mouseClick

open suspend override fun mouseClick(button: Input.MouseButton, modifiers: Int, clickCount: Int)

Performs a native mouse click using Chrome DevTools Protocol events.

Unlike click which uses JavaScript's element.click(), this method simulates actual mouse hardware events with the complete sequence: mouseMoved → mousePressed → mouseReleased.

When to use:

  • Testing click-outside behavior (closing overlays, modals, dropdowns)

  • Right-click or middle-click operations

  • Clicks with keyboard modifiers (Ctrl+Click, Shift+Click, etc.)

  • Situations where JavaScript click() doesn't work properly

  • Testing more realistic user interactions

When NOT to use:

  • Simple element clicks (use click instead - it's faster and more reliable)

Event sequence:

  1. mouseMoved - Moves cursor to element center

  2. mousePressed - Button down event

  3. mouseReleased - Button up event

The position is retrieved atomically to prevent race conditions.

Parameters

button

Which mouse button to use (default: LEFT)

modifiers

Keyboard modifiers as bitmask: Alt=1, Ctrl=2, Meta/Command=4, Shift=8 (default: 0). Multiple modifiers can be combined, e.g., Ctrl+Shift = 2+8 = 10

clickCount

Number of clicks: 1=single click, 2=double click, etc. (default: 1)

See also

For JavaScript-based clicking (recommended for most cases)

For moving mouse without clicking (hover effects)