Overview
TestDriver provides custom error classes with rich debugging information. These are exported from the SDK and can be used forinstanceof checks in your tests.
ElementNotFoundError
Thrown whenfind() cannot locate an element on screen, or when calling click()/hover() on an unfound element.
Properties
Always
"ElementNotFoundError".Enhanced message with a debug block containing element description, cache status, similarity scores, and AI response details.
The original element description passed to
find().Absolute path to a debug screenshot saved at the time of failure. Written to
<os.tmpdir>/testdriver-debug/screenshot-<timestamp>.png.Absolute path to a pixel diff image showing the comparison between the cached and current screenshots. Written to
<os.tmpdir>/testdriver-debug/pixel-diff-error-<timestamp>.png. Only present when cache was involved.URL to the cached image that was compared against.
Sanitized AI response object. Large binary fields (
croppedImage, screenshot, pixelDiffImage) are removed. Contains cache metadata like similarity, cacheHit, cacheStrategy, cacheDiffPercent, and threshold.ISO 8601 timestamp of when the error was created.
Enhanced Message
The error message is automatically enhanced with debugging information:Stack Trace Cleaning
Stack traces are automatically cleaned to remove internal SDK frames (Element.*, sdk.js internals), showing only your test code for easier debugging.
AIError
Thrown whenact() exhausts all retry attempts.
Properties
Always
"AIError".Enhanced message with execution details block.
The task description passed to
act().Number of attempts that were made.
Maximum number of attempts configured.
Total execution time in milliseconds.
The underlying error that caused the final failure.
ISO 8601 timestamp of when the error was created.
Enhanced Message
Internal Error Classes
These errors are used internally by the agent and are not exported, but may appear as thecause of an AIError:
MatchError
Thrown when element matching fails (text, image, or assertion).| Property | Type | Description |
|---|---|---|
fatal | boolean | If true, cannot be healed. Default: false |
attachScreenshot | boolean | Always true — a screenshot is attached to the error |
CommandError
Thrown for invalid arguments or unsupported operations.| Property | Type | Description |
|---|---|---|
fatal | boolean | Always true |
attachScreenshot | boolean | Always false |
Soft Assert Mode
Insideact(), assertions run in soft assert mode. When an assertion fails, it returns the failure result instead of throwing, allowing the AI to process the failure and adjust its approach.
assert() calls outside of act() will throw normally on failure.

