Overview
Find UI elements on the screen with natural language descriptions and AI. This returns anElement object. You can interact with the object.
Syntax
Parameters
string
required
Natural language description of the element to find
object | number
Optional configuration for finding and caching
Returns
Promise<Element> - The Element instance that TestDriver found automatically.
Examples
Basic Element Finding
Finding with Context
Interacting with Found Elements
Element Object
TheElement object that TestDriver returns gives these:
Methods
found()- Make a check if TestDriver found the elementclick(action)- Click the elementhover()- Put the cursor on the elementdoubleClick()- Double-click the elementrightClick()- Right-click the elementfind(newDescription)- Find the element again with an 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
You can serialize elements safely withJSON.stringify() for logs and for debug. TestDriver removes circular references automatically:
- To debug problems with element detection
- To log the details of the test
- To share element data between processes
- To examine the cache performance
Best Practices
Be specific in descriptionsMore specific descriptions make the accuracy better:
Always check if foundMake sure that TestDriver found the elements before you interact with them:
Include visual or positional context
Confidence Threshold
Set a minimum confidence score for element matches. If the confidence is less than the threshold,find() makes the result “not found”:
- Critical test steps. An incorrect click can cause more failures.
- To tell the difference between similar elements (for example, many buttons)
- To fail quickly when the UI changed
Element Type
Use thetype option to show which kind of element you look for. This puts your description into a more specific prompt for the AI. It makes the match accuracy better, primarily when a description is short or not clear.
Polling for Dynamic Elements
By default,find() polls for a maximum of 10 seconds (it tries again each 5 seconds) until it finds the element. You can change this with the timeout option:
timeout option:
- Has a default of
10000(10 seconds) - Tries to find the element again each 5 seconds
- Stops when it finds the element or the timeout ends
- Logs the progress during the poll
- Returns the element (make a check with
element.found()if it does not throw an error on a failure) - Set it to
0to disable the poll and try one time
Zoom Mode
Zoom mode is disabled by default. It uses a two-phase method for more precision when it finds elements, primarily in full UIs that have many similar elements. To enable zoom for a specific find call, givezoom: true:
How Zoom Mode Works
- Phase 1: The AI finds the approximate location of the element.
- Phase 2: TestDriver makes a 30% crop of the screen around that location.
- Phase 3: The AI does the precise location on the cropped image.
- Result: TestDriver changes the coordinates back to the absolute screen position.
Verify Mode
Verify mode is disabled by default. When it is enabled, a second AI call makes sure that the coordinates fromfind() agree with the correct element. This catches incorrect positions.
How Verify Mode Works
- Phase 1: The AI finds the element and returns coordinates.
- Phase 2: A second AI call looks at the screenshot at those coordinates. It makes sure that the element agrees with the description.
- Result: If the verification fails, TestDriver tries the find again or marks it “not found”.
Combining Zoom and Verify
For the maximum accuracy, enablezoom and verify together. Use this for critical interactions. A click on the wrong element can cause more failures:
Cache Options
When a test completes correctly, TestDriver caches the result of eachfind(). On later runs, TestDriver uses the cached match again. It does not make a new AI call. This finds the same element much more quickly. The cache is in your dashboard. TestDriver shares it between runs. Read the Cache page to see how the match, the thresholds, and the invalidation work.
Control the cache to make the performance better, primarily when you use dynamic variables in prompts.
Custom Cache Key
UsecacheKey to keep the cache clean when prompts have variables:
Cache Threshold
Control how similar a cached result must be before TestDriver uses it again:Manual Polling (Alternative)
If you need custom poll 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
string
required
Natural language description of elements to find
object | number
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()
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

