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

testdriver:extract

Read information from the screen using AI and return it as a string

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

설치 방법 보기

포함된 파일(1)

  • SKILL.md6.9 KB

SKILL.md(원문)

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

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

Overview

Get information from the screen with AI. TestDriver returns it as a string. Describe what you want in natural language. The AI reads the screen and returns the correct value: text, numbers, labels, status messages, or other content on the screen.

assert() returns a boolean result. But extract() returns the real value. Thus you can store it, compare it, or use it in later steps and in framework assertions.

Syntax

const value = await testdriver.extract(description)
const value = await testdriver.extract({ description })

Parameters

<ParamField path="description" type="string" required> A natural language description of the information to read from the screen. </ParamField> <Info> `extract()` also accepts an options object, `extract({ description })`. This is the same as the positional form. The string form is the most common. </Info>

Returns

Promise<string> — The information from the screen. TestDriver returns the value as text. Parse it or cast it yourself if you need a number or another type.

Examples

Basic Extraction

// Read text content
const title = await testdriver.extract('the page title');
const heading = await testdriver.extract('the main heading text');

// Read numbers and prices
const price = await testdriver.extract('the total price shown in the cart');
const count = await testdriver.extract('the number of items in the list');

// Read status and confirmation values
const status = await testdriver.extract('the order status');
const orderNumber = await testdriver.extract('the order confirmation number');

Using the Extracted Value

// Store and reuse across steps
const orderNumber = await testdriver.extract('the order confirmation number');
console.log('Order:', orderNumber);

// Combine with framework assertions
import { expect } from 'vitest';

const message = await testdriver.extract('the success message text');
expect(message).toContain('successfully');

// Cast to a number when you need to compare
const totalText = await testdriver.extract('the cart total as a number without currency symbol');
expect(Number(totalText)).toBeGreaterThan(0);

Best Practices

<Check> **Be specific about what to read**

Precise descriptions produce cleaner values:

// ❌ Too vague — may return extra surrounding text
const price = await testdriver.extract('price');

// ✅ Specific — targets a single value
const price = await testdriver.extract('the total price in the order summary, digits only');
</Check> <Check> **Ask for the format you want**

Steer the output by describing the desired shape in the prompt:

// Strip currency symbols
const total = await testdriver.extract('the order total as a number without the dollar sign');

// Isolate a single field
const email = await testdriver.extract('the email address shown in the profile header');
</Check> <Check> **Extract for detailed assertions**

Use extract() when a boolean assert() isn't enough and you need the actual value to inspect:

const confirmation = await testdriver.extract('the confirmation number');
expect(confirmation).toMatch(/^ORD-\d{6}$/);
</Check>

Use Cases

<AccordionGroup> <Accordion title="Capturing Confirmation Details"> ```javascript const submitBtn = await testdriver.find('place order button'); await submitBtn.click();
// Read the confirmation the app generated
const orderNumber = await testdriver.extract('the order confirmation number');
const eta = await testdriver.extract('the estimated delivery date');

console.log(`Order ${orderNumber} arrives ${eta}`);
```
</Accordion> <Accordion title="Reading Tooltip and Hover Content"> ```javascript const icon = await testdriver.find('info icon next to the price'); await icon.hover();
const tooltipText = await testdriver.extract('the tooltip text');
expect(tooltipText).toContain('tax included');
```
</Accordion> <Accordion title="Verifying Dynamic Values"> ```javascript // Read a value before an action const before = await testdriver.extract('the account balance');
const addBtn = await testdriver.find('add funds button');
await addBtn.click();

// Read it again after and compare
const after = await testdriver.extract('the account balance');
expect(Number(after.replace(/[^0-9.]/g, ''))).toBeGreaterThan(
  Number(before.replace(/[^0-9.]/g, ''))
);
```
</Accordion> <Accordion title="Passing Data Between Steps"> ```javascript // Read a generated code on one screen... const resetCode = await testdriver.extract('the password reset code');
// ...and type it into the next
const codeField = await testdriver.find('reset code input');
await codeField.click();
await testdriver.type(resetCode);
```
</Accordion> </AccordionGroup>

Complete Example

import { beforeAll, afterAll, describe, it, expect } from 'vitest';
import TestDriver from 'testdriverai';

describe('Extraction', () => {
  let testdriver;

  beforeAll(async () => {
    testdriver = new TestDriver(process.env.TD_API_KEY);
    await testdriver.auth();
    await testdriver.connect();
  });

  afterAll(async () => {
    await testdriver.disconnect();
  });

  it('should capture the order confirmation', async () => {
    await testdriver.focusApplication('Google Chrome');

    // Complete a checkout
    const checkoutBtn = await testdriver.find('checkout button');
    await checkoutBtn.click();

    const placeOrderBtn = await testdriver.find('place order button');
    await placeOrderBtn.click();

    // Verify we reached confirmation
    await testdriver.assert('the order confirmation page is displayed');

    // Extract the details the app generated
    const orderNumber = await testdriver.extract('the order confirmation number');
    const total = await testdriver.extract('the order total as a number without currency symbol');

    // Assert on the extracted values
    expect(orderNumber).toBeTruthy();
    expect(Number(total)).toBeGreaterThan(0);
  });
});

How It Works

  1. TestDriver captures a screenshot of the current screen
  2. The image and your description are sent to the TestDriver API
  3. The AI reads the requested information from the screenshot
  4. The extracted value is returned as a string
<Note> Like [assertions](/making-assertions), `extract()` reads the screen fresh on every call — it is not cached — so it always reflects the current state of the app. </Note>

Related Methods

  • assert() - Verify screen state with a boolean AI judgment
  • find() - Locate elements to interact with
  • parse() - Detect all UI elements on screen

리뷰

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

댓글

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

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

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

0 / 1,000자

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

같은 저장소의 스킬

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

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

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

Execute natural language tasks using AI

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

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

Make AI-powered assertions about screen state

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

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

Deploy TestDriver on your AWS infrastructure using CloudFormation

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

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

Speed up tests with screenshot-based caching

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

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

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

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

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

testdriverai의 스킬 모두 보기

이 스킬의 문제 신고