Overview
TestDriver’s element finding system uses AI to locate elements on screen using natural language descriptions. Thefind() method returns an Element object that you can interact with.
Finding Elements
find()
Locate an element on screen using a natural language description.description(string) - Natural language description of the element to find
Promise<Element> - Element instance that has been located
Example:
Element Class
TheElement 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.boolean - True if element coordinates were found
Example:
find()
Re-locate the element, optionally with a new description.newDescription(string, optional) - New description to search for
Promise<Element> - This element instance
Example:
click()
Click on the element.action(string, optional) - Type of click:'click'(default),'double-click','right-click','hover','mouseDown','mouseUp'
Promise<void>
Example:
The element must be found before clicking. The
find() method automatically locates the element.hover()
Hover over the element without clicking.Promise<void>
Example:
doubleClick()
Double-click on the element.Promise<void>
Example:
rightClick()
Right-click on the element to open context menu.Promise<void>
Example:
mouseDown() / mouseUp()
Press or release mouse button on the element (for drag operations).Promise<void>
Example:
Properties
Element properties provide additional information about located elements. Properties are available after a successfulfind() call.
coordinates
Get the element’s coordinates object containing all position information.Object | null - Coordinate object with { x, y, centerX, centerY }
Example:
x, y, centerX, centerY
Direct access to coordinate values. Always available after successfulfind().
width, height
Element dimensions in pixels. Available when AI detects element bounds.boundingBox
Complete bounding box information including position and dimensions.Object | null - Bounding box with all dimension data
screenshot
Base64-encoded PNG screenshot of the screen when element was found. Only available in DEBUG mode or when an error occurs.string | null - Base64-encoded PNG image
Example:
text
Text content extracted from the element by AI (if available).string | null - Element’s text content
Example:
label
Accessible label or name of the element (if available). Useful for verifying accessibility.string | null - Accessible label
Example:
confidence
AI confidence score for the element match (0-1, where 1 is perfect confidence).number | null - Confidence score between 0 and 1
Example:
Property Availability
| Property | When Available |
|---|---|
x, y, centerX, centerY | ✅ Always after successful find() |
coordinates | ✅ Always after successful find() |
width, height | ⚠️ When AI detects element bounds |
boundingBox | ⚠️ When AI detects element bounds |
text | ⚠️ When AI extracts text content |
label | ⚠️ When element has accessible label |
confidence | ✅ Always after AI element finding |
screenshot | ⚠️ Only in DEBUG mode or on errors |
Properties marked with ⚠️ may be
null depending on what the AI could detect from the screenshot.JSON Serialization
Element objects can be safely serialized usingJSON.stringify() for logging, debugging, and data storage. Circular references are automatically removed:
| Property | Type | Description |
|---|---|---|
description | string | Element search description |
coordinates | object | Full coordinate object {x, y, centerX, centerY} |
found | boolean | Whether element was located |
threshold | number | Cache threshold used for this find |
x, y | number | Top-left coordinates |
cache.hit | boolean | Whether cache was used |
cache.strategy | string | Cache strategy (e.g., “pixel-diff”) |
cache.createdAt | string | ISO timestamp when cache was created |
cache.diffPercent | number | Pixel difference from cached image |
cache.imageUrl | string | URL to cached screenshot |
similarity | number | Similarity score (0-1) |
confidence | number | AI confidence score (0-1) |
selector | string | CSS/XPath selector if available |
aiResponse | string | AI’s explanation of what it found |
Examples
Basic Element Interaction
Working with Forms
Conditional Interactions
Re-locating Dynamic Elements
Best Practices
Be specific with descriptions
Be specific with descriptions
Include visual details, position context, and nearby text:
Check if element was found
Check if element was found
Always verify elements were located before interacting:
Reuse element references when possible
Reuse element references when possible
If you need to interact with the same element multiple times, reuse the reference:

