Overview

The Extract Value step allows you to extract text content from elements and store it in a variable for use in subsequent steps. This is essential for creating dynamic tests that can work with generated content, IDs, or other values that change between test runs.

Form Fields

Field NameTypeRequiredDescription
LocatorstringYesCSS selector for the element to extract from
Variable NamestringYesAlphanumeric name to store the extracted value

Form Configuration

Locator Field

  • Text input field for entering CSS selectors
  • Supports element picker for visual selection
  • Should target the element containing the text to extract

Variable Name Field

  • Text input for naming the extracted variable
  • Must be alphanumeric only (no spaces or special characters)
  • Used to reference the extracted value in later steps
  • Should be descriptive and unique within the test case

Examples

Extract Order ID

  • Locator: #order-confirmation .order-id
  • Variable Name: orderId

Extract User Email

  • Locator: .user-profile .email-display
  • Variable Name: userEmail

Extract Generated Token

  • Locator: [data-testid='api-token']
  • Variable Name: authToken

Extract Dynamic URL

  • Locator: .share-link input
  • Variable Name: shareUrl

Extract Transaction ID

  • Locator: .receipt .transaction-number
  • Variable Name: transactionId

Best Practices

Locator Selection

  • Use specific, stable CSS selectors that target text-containing elements
  • Prefer data-testid attributes for better test reliability
  • Ensure the locator uniquely identifies the element with the desired text

Variable Naming

  • Use descriptive, meaningful names that indicate the content type
  • Follow consistent naming conventions (e.g., camelCase)
  • Keep names alphanumeric only - no spaces, hyphens, or special characters
  • Make names unique within your test case to avoid conflicts

Content Extraction

  • Ensure the target element contains plain text content
  • Account for dynamic content that may take time to load
  • Consider using Wait for Element before extracting if content loads dynamically

Common Issues

Element Not Found

  • Verify the locator correctly targets the element
  • Ensure the element is visible and contains text content
  • Add wait conditions if the element loads dynamically

Empty or Invalid Content

  • Check that the target element actually contains text
  • Verify the element isn’t empty or still loading
  • Consider timing issues with dynamic content

Variable Name Conflicts

  • Ensure variable names are unique within the test case
  • Use descriptive names to avoid confusion
  • Check for case sensitivity in variable names

Text Content Issues

  • The step extracts the text content of elements, not attribute values
  • For input field values, target the input element itself
  • Handle formatted text and whitespace appropriately

Use Cases

Dynamic IDs and References

  • Extract generated order numbers, user IDs, or transaction references
  • Store API keys or tokens for use in subsequent API calls
  • Extract database IDs for record verification

User-Generated Content

  • Extract usernames, email addresses, or profile information
  • Store form-generated values for verification steps
  • Extract calculated totals or dynamic pricing
  • Extract generated URLs for sharing or verification
  • Store redirect URLs for navigation testing
  • Extract download links or file references

Data Verification

  • Extract displayed values for comparison in later steps
  • Store timestamps or dates for temporal verification
  • Extract status messages or notifications

Using Extracted Values

Once extracted, variables can be used in subsequent steps:

In Fill Steps

  • Enable “Use variables Toggle” and select the variable from the dropdown
  • Use for filling forms with previously extracted data

In Check Text Steps

  • Enable “Use variables Toggle” and select the variable for text verification
  • Verify that extracted values appear correctly in other elements

In Navigate Steps

  • Enable “Use variables Toggle” and use extracted URLs for navigation
  • Navigate to dynamically generated pages or resources

In API Request Steps

  • Use extracted tokens, IDs, or values in API request parameters
  • Build dynamic API calls based on extracted content
  • Fill - For using extracted values in form fields
  • Check Text - For verifying extracted values appear elsewhere
  • Navigate - For navigating to extracted URLs
  • Wait for Element - For waiting on dynamic content before extraction