Overview
Locate UI elements on screen using AI-powered natural language descriptions. Returns anElement object that can be interacted with.
Syntax
Parameters
Natural language description of the element to find
Optional configuration for finding and caching
Returns
Promise<Element> - Element instance that has been automatically located
Examples
Basic Element Finding
Finding with Context
Interacting with Found Elements
Element Object
The returnedElement object provides:
Methods
found()- Check if element was locatedclick(action)- Click the elementhover()- Hover over the elementdoubleClick()- Double-click the elementrightClick()- Right-click the elementfind(newDescription)- Re-locate with optional new description
Properties
coordinates- Element position{x, y, centerX, centerY}x,y- Top-left coordinatescenterX,centerY- Center coordinatestext- Text content (if available)screenshot- Base64 screenshot (if available)confidence- AI confidence scorewidth,height- Element dimensionsboundingBox- Complete bounding box
JSON Serialization
Elements can be safely serialized usingJSON.stringify() for logging and debugging. Circular references are automatically removed:
- Debugging element detection issues
- Logging test execution details
- Sharing element information across processes
- Analyzing cache performance
Best Practices
Be specific in descriptionsMore specific descriptions improve accuracy:
Always check if foundVerify elements were located before interacting:
Include visual or positional context
Confidence Threshold
Require a minimum AI confidence score for element matches. If the confidence is below the threshold,find() treats the result as not found:
- Critical test steps where an incorrect click could cause cascading failures
- Distinguishing between similar elements (e.g., multiple buttons)
- Failing fast when the UI has changed unexpectedly
Element Type
Use thetype option to hint what kind of element you’re looking for. This wraps your description into a more specific prompt for the AI, improving match accuracy — especially when users provide short or ambiguous descriptions.
| Type | Prompt sent to AI |
|---|---|
"text" | The text "..." |
"image" | The image "..." |
"ui" | The UI element "..." |
"any" | Original description (no wrapping) |
Polling for Dynamic Elements
By default,find() polls for up to 10 seconds (retrying every 5 seconds) until the element is found. You can customize this with the timeout option:
timeout option:
- Defaults to
10000(10 seconds) - Retries finding the element every 5 seconds
- Stops when the element is found or the timeout expires
- Logs progress during polling
- Returns the element (check
element.found()if not throwing on failure) - Set to
0to disable polling and make a single attempt
Zoom Mode
Zoom mode is disabled by default. It uses a two-phase approach for better precision when locating elements, especially in crowded UIs with many similar elements. To enable zoom for a specific find call, passzoom: true:
How Zoom Mode Works
- Phase 1: AI identifies the approximate location of the element
- Phase 2: A 30% crop of the screen is created around that location
- Phase 3: AI performs precise location on the zoomed/cropped image
- Result: Coordinates are converted back to absolute screen position
Verify Mode
Verify mode is disabled by default. When enabled, a second AI call checks that the coordinates returned byfind() actually correspond to the requested element, catching hallucinated or incorrect positions.
How Verify Mode Works
- Phase 1: AI locates the element and returns coordinates
- Phase 2: A second AI call examines the screenshot at those coordinates to confirm the element matches the description
- Result: If verification fails, the find is retried or marked as not found
Combining Zoom and Verify
For maximum accuracy, enable bothzoom and verify together. This is useful for critical interactions where clicking the wrong element could cause cascading failures:
Cache Options
When a test completes successfully, the result of eachfind() is cached. On later runs, TestDriver reuses the cached match instead of making a fresh AI call, which significantly speeds up locating the same element. The cache lives in your dashboard and is shared across runs — see the Cache page for how matching, thresholds, and invalidation work.
Control caching behavior to optimize performance, especially when using dynamic variables in prompts.
Custom Cache Key
UsecacheKey to prevent cache pollution when prompts contain variables:
Cache Threshold
Control how similar a cached result must be to reuse it:Manual Polling (Alternative)
If you need custom polling logic:Use Cases
Form Fields
Form Fields
Dynamic Content
Dynamic Content
Complex UI Elements
Complex UI Elements
Complete Example
Related Methods
click()- Click on found elementshover()- Hover over elementsassert()- Verify element states- Elements Reference - Complete Element API
findAll()
Locate all elements matching a description, rather than just one.Syntax
Parameters
Natural language description of elements to find
Optional cache options (same as
find())Returns
Promise<Element[]> - Array of Element instances
Examples
Basic Usage
Finding Multiple Items
With Caching
Empty Results
Differences from find()
| Feature | find() | findAll() |
|---|---|---|
| Return type | Single Element | Array of Element[] |
| If nothing found | Throws ElementNotFoundError | Returns empty array [] |
| Chainable | ✅ Yes: await find('button').click() | ❌ No (returns array) |
| Use case | One specific element | Multiple similar elements |
| Cache support | ✅ Yes | ✅ Yes |
Use Cases
Table Rows
Table Rows
Conditional Interactions
Conditional Interactions
Complete Example
Best Practices
Handle empty arrays gracefully
Use find() for single elements
Cache for performance

