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. Unlikeassert(), 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
Capturing Confirmation Details
Capturing Confirmation Details
Reading Tooltip and Hover Content
Reading Tooltip and Hover Content
Verifying Dynamic Values
Verifying Dynamic Values
Passing Data Between Steps
Passing Data Between Steps
Complete Example
How It Works
- TestDriver captures a screenshot of the current screen
- The image and your description are sent to the TestDriver API
- The AI reads the requested information from the screenshot
- 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.
