Skip to main content

Overview

The mouseDown() 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 an Element, no parameters are required. When called directly on the AI client:

Returns

It returns a Promise<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() with mouseUp() 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"