assert() tells you whether something is true. extract() gives you the value itself, so you can compare it, log it, or type it somewhere else.
Signature
Parameters
string
required
What to read from the screen, such as
'the total price in the order summary'. Say what format you want, too: 'the cart total as a number, without the dollar sign'.Returns
Promise<string>. The value the AI read, with no extra text. Convert it yourself when you need a number or another type.
Errors
extract() throws if the AI service fails, for example when it’s temporarily unavailable.
It doesn’t throw when the value isn’t on screen. Check the result before you rely on it.
Examples
Compare a value with expect()
Read a number
Check the format of a generated value
Pass a value to the next step
Read text that appears on hover
How it works
- TestDriver takes a screenshot of the sandbox.
- It sends the screenshot and your description to the AI.
- The AI returns only the value you asked for.
Complete example
tests/login.test.mjs
Related
- assert(): check a statement about the screen
- Make assertions: choose between
assert()andextract() - find(): locate an element to act on
- parse(): list every element on screen

