Skip to main content

Overview

TestDriver’s element finding system uses AI to locate elements on screen using natural language descriptions. The find() method returns an Element object that you can interact with.

Finding Elements

find()

Locate an element on screen using a natural language description.
Parameters:
  • description (string) - Natural language description of the element to find
Returns: Promise<Element> - Element instance that has been located Example:
Be specific in your descriptions. Include visual details, location context, or nearby text to improve accuracy.

Element Class

The Element class represents a located (or to-be-located) UI element. It provides methods for interaction and properties for element information.

Methods

found()

Check if the element was successfully located.
Returns: boolean - True if element coordinates were found Example:

find()

Re-locate the element, optionally with a new description.
Parameters:
  • newDescription (string, optional) - New description to search for
Returns: Promise<Element> - This element instance Example:

click()

Click on the element.
Parameters:
  • action (string, optional) - Type of click: 'click' (default), 'double-click', 'right-click', 'hover', 'mouseDown', 'mouseUp'
Returns: Promise<void> Example:
The element must be found before clicking. The find() method automatically locates the element.

hover()

Hover over the element without clicking.
Returns: Promise<void> Example:

doubleClick()

Double-click on the element.
Returns: Promise<void> Example:

rightClick()

Right-click on the element to open context menu.
Returns: Promise<void> Example:

mouseDown() / mouseUp()

Press or release mouse button on the element (for drag operations).
Returns: Promise<void> Example:

Properties

Element properties provide additional information about located elements. Properties are available after a successful find() call.

coordinates

Get the element’s coordinates object containing all position information.
Returns: Object | null - Coordinate object with { x, y, centerX, centerY } Example:

x, y, centerX, centerY

Direct access to coordinate values. Always available after successful find().
Example:

width, height

Element dimensions in pixels. Available when AI detects element bounds.
Example:

boundingBox

Complete bounding box information including position and dimensions.
Returns: Object | null - Bounding box with all dimension data
Example:

screenshot

Base64-encoded PNG screenshot of the screen when element was found. Only available in DEBUG mode or when an error occurs.
Returns: string | null - Base64-encoded PNG image Example:
Screenshots can be large. They’re automatically excluded from error messages to prevent memory issues.

text

Text content extracted from the element by AI (if available).
Returns: string | null - Element’s text content Example:

label

Accessible label or name of the element (if available). Useful for verifying accessibility.
Returns: string | null - Accessible label Example:

confidence

AI confidence score for the element match (0-1, where 1 is perfect confidence).
Returns: number | null - Confidence score between 0 and 1 Example:
Confidence scores below 0.8 may indicate the element description was ambiguous or the wrong element was found.

Property Availability

Properties marked with ⚠️ may be null depending on what the AI could detect from the screenshot.

JSON Serialization

Element objects can be safely serialized using JSON.stringify() for logging, debugging, and data storage. Circular references are automatically removed:
Serialized output includes:
Serialized properties: Use cases:
Use JSON serialization when you need to log element data or when debugging why an element wasn’t found. The serialized output excludes large binary data (screenshots) and circular references.

Examples

Basic Element Interaction

Working with Forms

Conditional Interactions

Re-locating Dynamic Elements

Best Practices

Include visual details, position context, and nearby text:
Always verify elements were located before interacting:
If you need to interact with the same element multiple times, reuse the reference: