Skip to main content

Overview

Extract information from the current screen using AI and return it as a string. Describe what you want in natural language, and the AI reads the screen and returns the matching value — text, numbers, labels, status messages, or any other on-screen content. Unlike assert(), which returns a boolean verdict, extract() returns the actual value so you can store it, compare it, or feed it into later steps and framework assertions.

Syntax

Parameters

string
required
Natural language description of the information to read from the screen.
extract() also accepts an options object — extract({ description }) — which is equivalent to the positional form. The bare string form is the most common.

Returns

Promise<string> — The information read from the screen. Returns the extracted value as text; parse or cast it yourself if you need a number or other type.

Examples

Basic Extraction

Using the Extracted Value

Best Practices

Be specific about what to readPrecise descriptions produce cleaner values:
Ask for the format you wantSteer the output by describing the desired shape in the prompt:
Extract for detailed assertionsUse extract() when a boolean assert() isn’t enough and you need the actual value to inspect:

Use Cases

Complete Example

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
Like assertions, extract() reads the screen fresh on every call — it is not cached — so it always reflects the current state of the app.
  • assert() - Verify screen state with a boolean AI judgment
  • find() - Locate elements to interact with
  • parse() - Detect all UI elements on screen