- When the screen looks the same on a later run,
find()reuses that location instead of asking the AI. - The step is faster, cheaper, and gives the same result every time.
- When the screen changes, TestDriver falls back to the AI and learns the new location.
How caching works
-
The first run learns. Each
find()asks the AI to locate the element. TestDriver saves the result with an image of the screen and of the element. - A passing run confirms. Saved entries become usable only once the test passes. A failing run never teaches TestDriver a wrong location.
-
Later runs reuse. On the next run,
find()compares the current screen with the saved one. TestDriver returns the saved location without calling the AI when both are true:- The screen differs by no more than 5% of its pixels.
- The saved image of the element still matches whatβs at that spot.
assert() is cached the same way. When the screen matches a confirmed earlier run, the saved result is reused.
What has to match
A saved entry is reused only when all of these match the run that created it:- The test file. The cache is keyed on a hash of the test fileβs contents, so editing the file starts a fresh cache. A changed test canβt reuse results that no longer apply.
- The description. The text you pass to
find()must match exactly. - The OS and screen resolution of the sandbox.
Keep changing values out of descriptions
The description must match exactly. A description with a value that changes between runs misses the cache every time:Choose your own cache key
By default, each test file has its own cache, which resets when you edit the file. Set acacheKey when you create the client to keep the cache across edits, or to share it between files that use the same screens:
cacheKey to a single find() call.
A stable key doesnβt make TestDriver reuse a location for a changed page. Entries are still reused only when the description, OS, and resolution match and the screen looks the same.
Adjust how closely the screen must match
Two thresholds control when a saved location is reused:
Set them for every call when you create the client:
screen and higher element values make reuse stricter. That helps on screens where small details matter, but costs more AI calls.
For every cache option, see Configure the cache.
Turn caching off
Disable caching for a client withcache: false, or for a whole run with TD_NO_CACHE:
See whatβs cached
The Cache page in the TestDriver console lists your teamβs cached elements and assertions. It shows a preview and the description for each, and lets you clear entries. To check a singlefind() in your test, read the cache details from the element:
Next steps
Configure the cache
Every cache option, threshold, and override.
Locate elements
Write descriptions that find the right element and cache well.
Run tests
Run your tests locally and in parallel.
Run in CI/CD
Run cached tests on every pull request.

