Why this works: Extract generated URLs and navigate to them to verify sharing functionality.
## Best Practices
### Write Stable Selectors
- Target elements with unique, stable attributes: `[data-testid='confirmation-code']`
- Use semantic selectors that reflect content: `.user-id`, `#transaction-number`
- Avoid brittle selectors based on layout: `div:nth-child(3) > span:first-child`
### Name Variables Clearly
Your variable names should:
- Describe what they contain: `customerName`, not `name1`
- Use consistent naming style: stick with camelCase or snake_case
- Be memorable enough to use steps later without confusion
- Avoid generic names like `value`, `data`, or `text`
### Handle Timing Correctly
- Add [Wait for Element](/steps/wait-for-element) if content loads dynamically
- Ensure the element contains text before extracting
- Account for animations or transitions that might delay content appearance
### Plan Your Data Flow
Think about how extracted values flow through your test:
- What data do you need to extract early?
- Which later steps will use this data?
- Do you need to extract multiple related values?
- Will the data persist across page navigations?
## Troubleshooting
### Element Not Found
**Symptom**: Test fails saying it can't find the element
**Solution**:
- Use the element picker to verify your selector
- Check that the element exists when the step runs
- Add a [Wait for Element](/steps/wait-for-element) if content loads asynchronously
### Extracted Value Is Empty
**Symptom**: Variable is created but contains empty or whitespace
**Solution**:
- Verify the element contains visible text content
- Check if text is in a child element rather than the target element
- Ensure the element has fully loaded before extraction
- Look for timing issues with dynamic content
### Variable Not Available in Later Steps
**Symptom**: "Use variables" dropdown doesn't show your variable
**Solution**:
- Verify the Extract Value step ran successfully
- Check that the variable name is alphanumeric only
- Ensure the variable name is unique in your test
- Confirm you're looking for the variable in a step that comes AFTER extraction
### Wrong Content Extracted
**Symptom**: Variable contains unexpected or partial text
**Solution**:
- Confirm your selector targets the right element (use element picker)
- Check if the element contains child elements with additional text
- Verify you're extracting text content, not attribute values
- Look for whitespace or formatting that might be included
## Using Extracted Values
Once you extract a value, it becomes available in the "Use variables" dropdown for these steps:
**Fill Steps**: Use extracted text to fill form fields with dynamic data
**Check Text Steps**: Verify that extracted values appear correctly in other elements
**Check URL Steps**: Use extracted URLs or parameters to verify navigation
**Navigate Steps**: Navigate to extracted URLs or dynamic paths
**API Request Steps**: Use extracted IDs or tokens in API calls
## Related Steps
- [Fill](/steps/fill) - Use extracted values to fill form fields
- [Check Text](/steps/verify-value) - Verify extracted values appear elsewhere
- [Check URL](/steps/verify-url) - Verify URLs match extracted patterns
- [Wait for Element](/steps/wait-for-element) - Wait for dynamic content before extraction