Extract from element
Command value: extract
Reads the text of an element into a variable.
Fields
| Field | JSON property | Description |
|---|---|---|
| Variable Name | variable_name | Name to store the result under. Reference it in later steps as {{NAME}}. |
| CSS or XPath Selector | target | Element the step acts on, for example #login, .cart button or //button[text()='Save']. |
Usage
- Capture an order number or generated id, then use {{NAME}} in a later assertion or request.
- Stores the visible text of the element.
Example step (JSON)
{
"command": "extract",
"target": ".order-id",
"variable_name": "ORDER_ID"
}Playwright equivalent
const ORDER_ID = (await page.locator('.order-id').textContent()) ?? '';Common options
- Make this step optional (Continue on failure): when checked, a failure in this step is recorded and the test continues with the next step.
- Execute step when JavaScript returns true: runs the step only when the JavaScript condition returns true. Otherwise the step is skipped.
See conditional steps and variables for details.