mouseClick
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:
mouseMoved- Moves cursor to element centermousePressed- Button down eventmouseReleased- Button up event
The position is retrieved atomically to prevent race conditions.
Parameters
Which mouse button to use (default: LEFT)
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
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)