Overview
The Extract Value step extracts text content or attribute values from page elements using CSS selectors. The extracted value is stored in a variable that you can use in subsequent steps.When to Use Extract Value
Use Extract Value when you need to:- Capture displayed text: Extract visible text from elements like prices, order numbers, or status messages
- Extract attribute values: Get values from element attributes like
href,data-id, orvalue - Store data for later use: Save extracted values to use in subsequent steps
- Build dynamic workflows: Create test flows that adapt based on page content
Configuration
| Field | Type | Required | Description |
|---|---|---|---|
| Locator | CSS selector | Yes | Element to extract from |
| Extract Type | dropdown | Yes | What to extract: Text Content or Attribute |
| Attribute Name | text | Conditional | Required when Extract Type is Attribute |
| Variable Name | text | Yes | Name for storing the extracted value |
Locator
Use a CSS selector to identify the element. Examples:#order-number- Element with ID.price-total- Element with class[data-testid="confirmation-code"]- Element with data attributespan.order-id- Specific element type with class
Extract Type
Text Content: Extracts the visible text inside the element."ORD-123456"
Attribute: Extracts the value of a specified attribute.
data-order-id, extracts: "123"
Variable Name
The extracted value is stored in this variable. Access it in later steps using{{ vars.variableName }}.
Examples
Extract Order Number
"ORD-2024-78534"
Use in later steps: {{ vars.orderNumber }}
Extract Price
"$149.99"
Extract Link URL
"/files/report-2024.pdf"
Extract Input Value
"[email protected]"
Extract Data Attribute
"SKU-12345"
Real-World Scenarios
Capture and Verify Order Flow
Extract and Use in API Request
Multi-Value Extraction
- Locator:
.order-id - Variable Name:
orderId
"ORD-123456"
Access in later steps:
- In Fill step:
{{ vars.orderId }}→"ORD-123456" - In Verify Value step: Check if element contains
{{ vars.orderId }} - In API Request: Use in URL or body:
https://api.example.com/orders/{{ vars.orderId }}
Example: Extracting a Price
HTML on page:- Locator:
.cart-total .amount - Variable Name:
cartTotal
"$149.99"
Note: The extracted value includes all text content exactly as displayed, including currency symbols and formatting.
Example: Extracting User Email
HTML on page:- Locator:
.user-profile .email-display - Variable Name:
userEmail
"[email protected]"
Use in subsequent steps:
- Fill another email field:
{{ vars.userEmail }} - Verify it appears elsewhere: Check element contains
{{ vars.userEmail }} - Pass to API request: Include in request body or headers
Whitespace Handling
Extracted text preserves leading and trailing whitespace from the element’s text content. If you need trimmed values, consider using a Run Python step:Common Use Cases
Using Extracted API Keys
Transaction ID for Support Lookup
Extract Value vs AI Extract
| Feature | Extract Value | AI Extract |
|---|---|---|
| Selection method | CSS selector | Natural language prompt |
| Speed | Fast (direct DOM access) | Slower (AI processing) |
| AI Credits | None | 1 credit per use |
| Best for | Stable selectors | Dynamic content |
| Accuracy | Exact match required | Context-aware |
- Elements have reliable selectors (
data-testid, IDs, stable classes) - Speed matters
- You want to avoid AI credit usage
- Simple text or attribute extraction
- Elements lack stable selectors
- Content structure varies between runs
- You need visual context for extraction
Best Practices
Use Stable Selectors
Prefer selectors that won’t change:[data-testid="order-id"]- Test IDs are stable#confirmation-code- IDs are usually stable.order-summary .total- Specific class paths
.css-1a2b3c- Auto-generated classes changediv > div > span:nth-child(3)- Position-based, breaks easily
Name Variables Clearly
Use descriptive names:orderConfirmationNumbernotnumproductPricenotvaluserEmailAddressnotemail1
Handle Missing Elements
If the element might not exist, add error handling:Trim and Clean Values
Extracted text may include whitespace. Use expressions to clean:Troubleshooting
Element Not Found
Symptom: Step fails with “element not found” Solutions:- Verify the selector in browser DevTools
- Add a Wait for Element step before extraction
- Check if element is inside an iframe
- Ensure page has fully loaded
Wrong Value Extracted
Symptom: Extracted value is different than expected Solutions:- Make selector more specific to target the exact element
- Check if there are multiple matching elements (first one is used)
- Verify you’re using the correct Extract Type (Text vs Attribute)
Variable Not Available
Symptom:{{ vars.myVar }} doesn’t resolve
Solutions:
- Verify the Extract Value step completed successfully
- Check variable name spelling matches exactly
- Ensure the extraction step runs before the step using the variable
Empty Value Extracted
Symptom: Variable is empty string Solutions:- Check if element has visible text content
- For hidden elements, try extracting
textContentattribute - Verify the element isn’t dynamically populated after page load
Related Steps
- AI Extract - AI-powered extraction for dynamic content
- Fill - Use extracted values in form fields
- Verify Value - Verify extracted values
- Wait for Element - Ensure element exists before extraction

