Overview
ThemouseDown() method pushes the mouse button at the location of an element. It does not release the button. Use this for drag operations, custom gestures, or when you need precise control of the mouse events. You can call it on an Element instance. Or you can use it with a selector.
Syntax
Parameters
When called on anElement, no parameters are required.
When called directly on the AI client:
Returns
It returns aPromise<void>. The promise resolves when TestDriver pushes the mouse button.
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

