Overview
ThemouseDown() method presses the mouse button at an element’s location without releasing it. This is useful for drag operations, custom gestures, or when you need precise control over mouse events. You can either call it on an Element instance or use it directly with a selector.
Syntax
Parameters
When called on anElement, no parameters are required.
When called directly on the AI client:
| Parameter | Type | Description |
|---|---|---|
selector | string | The selector describing the element where the mouse button should be pressed |
Returns
Returns aPromise<void> that resolves when the mouse button is pressed.
Examples
Basic Drag Operation
Drag and Drop with Direct Selectors
Selecting Multiple Items
Custom Drawing Application
Long Press Gesture
Resizing UI Elements
Important Notes
- Always pair
mouseDown()withmouseUp()to complete the gesture - The mouse button remains pressed until
mouseUp()is called - Use
hover()to move the mouse while the button is pressed - For simple drag operations, consider using
ai()with a natural language description like"drag file to folder"
Related Methods
mouseUp()- Release the mouse buttonhover()- Move mouse to elementclick()- Full click (mouseDown + mouseUp)doubleClick()- Double-click on elementrightClick()- Right-click for context menu

