Skip to main content
TestDriver exports two error classes you can check with instanceof:
Other failures, such as a failed assertion, throw a plain Error with a recognizable message. See Other errors.

ElementNotFoundError

Thrown when you call an action on an element that find() didnโ€™t locate:
  • click(), doubleClick(), rightClick()
  • hover()
  • mouseDown(), mouseUp()
find() itself doesnโ€™t throw when nothing matches. It returns an element whose found() is false. Check found() when the element might not be there:

Properties

string
Always "ElementNotFoundError".
string
The description you passed to find().
string
Says which element wasnโ€™t found, followed by a debug block. See below.
object | null
The response from the find() call, with screenshots and other large images removed. Includes fields such as cacheHit, similarity, and reasoning when the API returned them.
string
When the error was created, as an ISO 8601 string.

Message

The message starts with the elementโ€™s description, then adds what TestDriver knows about the failed find():
Depending on the find() call, the debug block can also include:
  • The cache threshold and the required similarity.
  • When the cache was hit: the cache strategy, the entryโ€™s age, and the pixel difference.
  • The similarity score, marked (below threshold) when itโ€™s too low.
The stack trace starts at your test code, not inside the SDK.

AIError

Thrown when a task you give to ai() fails:
act() is the same method under another name and throws the same error.

Properties

string
Always "AIError".
string
The task you passed to ai().
number
How many check attempts were made.
number
The tries limit for the call. Defaults to 7.
number
How long the task ran, in milliseconds.
Error
The error that stopped the task.
string
When the error was created, as an ISO 8601 string.

Message

Other errors

These failures throw an error whose class isnโ€™t exported. Check the message instead.
Inside ai(), a failed assert() resolves to false instead of throwing, so the AI can see the result and try another approach.
  • find(): returns an element whose found() tells you whether it was located
  • assert(): check whatโ€™s on screen
  • Debug a failing test: find out why a test failed
  • Events: listen for errors as they happen