본문으로 건너뛰기
cccskills
무료GitHub에 공개

testdriver:errors

Custom error classes and error handling

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

설치 방법 보기

포함된 파일(1)

  • SKILL.md6.9 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

<!-- Generated from errors.mdx. DO NOT EDIT. -->

Overview

TestDriver gives custom error classes with full debug information. The SDK exports them. You can use them for instanceof checks in your tests.

import TestDriver, { ElementNotFoundError, AIError } from 'testdriverai';

ElementNotFoundError

TestDriver throws this when find() cannot find an element on the screen. It also throws this when you call click() or hover() on an element that TestDriver did not find.

try {
  await testdriver.find('nonexistent button').click();
} catch (error) {
  if (error instanceof ElementNotFoundError) {
    console.log(error.description);       // "nonexistent button"
    console.log(error.screenshotPath);    // path to debug screenshot
    console.log(error.pixelDiffPath);     // path to pixel diff image
  }
}

Properties

<ParamField path="name" type="string"> Always `"ElementNotFoundError"`. </ParamField> <ParamField path="message" type="string"> A message with a debug block. The block has the element description, the cache status, the similarity scores, and the AI response details. </ParamField> <ParamField path="description" type="string"> The original element description passed to `find()`. </ParamField> <ParamField path="screenshotPath" type="string | null"> Absolute path to a debug screenshot saved at the time of failure. Written to `<os.tmpdir>/testdriver-debug/screenshot-<timestamp>.png`. </ParamField> <ParamField path="pixelDiffPath" type="string | null"> 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. </ParamField> <ParamField path="cachedImagePath" type="string | null"> URL to the cached image that was compared against. </ParamField> <ParamField path="aiResponse" type="object | null"> Sanitized AI response object. Large binary fields (`croppedImage`, `screenshot`, `pixelDiffImage`) are removed. Contains cache metadata like `similarity`, `cacheHit`, `cacheStrategy`, `cacheDiffPercent`, and `threshold`. </ParamField> <ParamField path="timestamp" type="string"> ISO 8601 timestamp of when the error was created. </ParamField>

Enhanced Message

The error message is automatically enhanced with debugging information:

Element not found: "submit button"

=== Element Debug Info ===
Element: submit button
Cache Hit: false
Similarity: 0.23
Cache Strategy: pixel-diff
Threshold: 0.05
AI Response Element: null

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 when act() exhausts all retry attempts.

try {
  await testdriver.act('perform complex workflow', { tries: 3 });
} catch (error) {
  if (error instanceof AIError) {
    console.log(error.task);       // "perform complex workflow"
    console.log(error.tries);     // 3
    console.log(error.duration);  // 15234 (ms)
    console.log(error.cause);     // underlying Error
  }
}

Properties

<ParamField path="name" type="string"> Always `"AIError"`. </ParamField> <ParamField path="message" type="string"> Enhanced message with execution details block. </ParamField> <ParamField path="task" type="string"> The task description passed to `act()`. </ParamField> <ParamField path="tries" type="number"> Number of attempts that were made. </ParamField> <ParamField path="maxTries" type="number"> Maximum number of attempts configured. </ParamField> <ParamField path="duration" type="number"> Total execution time in milliseconds. </ParamField> <ParamField path="cause" type="Error | undefined"> The underlying error that caused the final failure. </ParamField> <ParamField path="timestamp" type="string"> ISO 8601 timestamp of when the error was created. </ParamField>

Enhanced Message

AI failed: Element not found after 3 attempts

=== AI Execution Details ===
Task: perform complex workflow
Tries: 3 / 3
Duration: 15234ms
Cause: ElementNotFoundError: Element not found: "submit button"

Internal Error Classes

These errors are used internally by the agent and are not exported, but may appear as the cause of an AIError:

MatchError

Thrown when element matching fails (text, image, or assertion).

PropertyTypeDescription
fatalbooleanIf true, cannot be healed. Default: false
attachScreenshotbooleanAlways true — a screenshot is attached to the error

CommandError

Thrown for invalid arguments or unsupported operations.

PropertyTypeDescription
fatalbooleanAlways true
attachScreenshotbooleanAlways false

Soft Assert Mode

Inside act(), 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.

// Inside act(), assertion failures don't throw
await testdriver.act('verify the dashboard shows correct data', {
  tries: 3,
});
// The AI can see assertion results and self-correct

This is automatic — you don't need to configure it. Regular assert() calls outside of act() will throw normally on failure.

Error Handling Patterns

Catching Specific Errors

import TestDriver, { ElementNotFoundError, AIError } from 'testdriverai';

try {
  await testdriver.find('submit button').click();
} catch (error) {
  if (error instanceof ElementNotFoundError) {
    // Element wasn't found — check screenshot for debugging
    console.log('Debug screenshot:', error.screenshotPath);
  } else if (error instanceof AIError) {
    // AI exhausted retries
    console.log(`Failed after ${error.tries} tries in ${error.duration}ms`);
  } else {
    throw error; // Unexpected error
  }
}

Using Debug Screenshots

try {
  const el = await testdriver.find('checkout button');
  await el.click();
} catch (error) {
  if (error instanceof ElementNotFoundError) {
    // Screenshot of what the screen looked like
    console.log('Screen:', error.screenshotPath);
    // Pixel diff showing cache comparison
    console.log('Diff:', error.pixelDiffPath);
    // Full AI response metadata
    console.log('AI:', JSON.stringify(error.aiResponse, null, 2));
  }
}

Types

class ElementNotFoundError extends Error {
  name: 'ElementNotFoundError';
  description: string;
  screenshotPath: string | null;
  pixelDiffPath: string | null;
  cachedImagePath: string | null;
  aiResponse: Record<string, any> | null;
  timestamp: string;
}

class AIError extends Error {
  name: 'AIError';
  task: string;
  tries: number;
  maxTries: number;
  duration: number;
  cause?: Error;
  timestamp: string;
}

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

How the TestDriver agent behaves on GitHub issues, pull requests, and @mentions

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

testdriverai/testdriverai4732026년 9월 21일 업데이트

Execute natural language tasks using AI

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

testdriverai/testdriverai4732026년 9월 21일 업데이트

Make AI-powered assertions about screen state

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

testdriverai/testdriverai4732026년 9월 21일 업데이트

Deploy TestDriver on your AWS infrastructure using CloudFormation

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

testdriverai/testdriverai4732026년 9월 21일 업데이트

Speed up tests with screenshot-based caching

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

testdriverai/testdriverai4732026년 9월 21일 업데이트

How TestDriver learns your app and caches what it discovers for instant, deterministic replays

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

testdriverai/testdriverai4732026년 9월 21일 업데이트

testdriverai의 스킬 모두 보기

이 스킬의 문제 신고