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
Parameters
string
required
A natural language description of the information to read from the screen.
extract() also accepts an options object, extract({ description }). This is the same as the positional form. The string form is the most common.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
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.
