Skip to main content

YAML Test Examples

This guide provides practical, real-world examples of YAML tests for common scenarios.

Important Note About Test Execution

All tests automatically navigate to the build URL (web) or open the app (mobile) when they start. You do NOT need to include manual navigate or open_app steps at the beginning of your tests. The examples below demonstrate the correct pattern: starting with instructions, validations, or extractions.

Basic Examples

Simple Validation (Web)

Test that verifies a page loads correctly:
test:
  metadata:
    name: "Homepage Load Test"
    platform: web

  build:
    name: "Marketing Site"

  blocks:
    - type: validation
      step_description: "The homepage has loaded"

    - type: validation
      step_description: "The main headline is visible"

    - type: validation
      step_description: "The navigation menu is displayed"

Mobile App Validation (iOS)

Test that verifies an app launches correctly:
test:
  metadata:
    name: "App Launch Test"
    platform: ios

  build:
    name: "Finance App"

  blocks:
    - type: validation
      step_description: "The home screen is visible"

    - type: validation
      step_description: "The account balance is displayed"

Login Flows

Simple Login (Web)

Basic login test with hardcoded credentials:
test:
  metadata:
    name: "User Login"
    platform: web

  build:
    name: "SaaS App"

  blocks:
    - type: instructions
      step_description: "Enter '[email protected]' in the email field"

    - type: instructions
      step_description: "Enter 'password123' in the password field"

    - type: instructions
      step_description: "Click the login button"

    - type: validation
      step_description: "The dashboard page is visible"

Login with High Level Instruction

Using variables for flexible credential management:
test:
  metadata:
    name: "Login with Variables"
    platform: web

  build:
    name: "SaaS App"

  blocks:
    # The agent will automatically complete all required steps
    - type: instructions
      step_description: "Login with the username 'test-user' and the password 'jdmm4K0UyHt4gwMz'"

    - type: validation
      step_description: "Successfully logged in"

Mobile Login with Biometrics Check

Login flow with conditional:
test:
  metadata:
    name: "Mobile Login with Biometrics"
    platform: ios

  build:
    name: "Banking App"

  blocks:
    - type: if
      condition: "Biometric authentication prompt is shown"
      then:
        - type: instructions
          step_description: "Dismiss the biometric prompt"

    - type: instructions
      step_description: "Enter '[email protected]' in the email field"

    - type: instructions
      step_description: "Enter 'securepass' in the password field"

    - type: instructions
      step_description: "Tap login"

    - type: validation
      step_description: "The home screen is visible"

Data Extraction and Validation

Extract and Verify Price

Ensuring price consistency across pages:
test:
  metadata:
    name: "Price Consistency Check"
    platform: web

  build:
    name: "E-commerce Site"

  blocks:
    # Start with product interaction
    - type: instructions
      step_description: "Click the first product"

    - type: extraction
      step_description: "The product price on the detail page"
      variable_name: detail-price

    - type: instructions
      step_description: "Click 'Add to Cart'"

    - type: instructions
      step_description: "Open the cart"

    - type: validation
      step_description: "The cart shows price of $detail-price$"

    - type: instructions
      step_description: "Proceed to checkout"

    - type: validation
      step_description: "The checkout total matches $detail-price$"

Extract Order ID for Later Use

Capturing data for verification:
test:
  metadata:
    name: "Order Confirmation"
    platform: web

  build:
    name: "Shopping Site"

  blocks:
    - type: instructions
      step_description: "Complete the checkout process"

    - type: extraction
      step_description: "The order confirmation number"
      variable_name: order-id

    - type: validation
      step_description: "Order confirmation displays 'Order #$order-id$'"

    - type: instructions
      step_description: "Navigate to order history"

    - type: validation
      step_description: "Order $order-id$ appears in the order list"

Extract Multiple Values

Working with multiple extracted variables:
test:
  metadata:
    name: "Shopping Cart Validation"
    platform: web

  build:
    name: "E-commerce Site"

  blocks:
    - type: instructions
      step_description: "Add first product to cart"

    - type: extraction
      step_description: "The first product price"
      variable_name: price-1

    - type: instructions
      step_description: "Continue shopping"

    - type: instructions
      step_description: "Add second product to cart"

    - type: extraction
      step_description: "The second product price"
      variable_name: price-2

    - type: instructions
      step_description: "Open cart"

    - type: validation
      step_description: "First item shows price $price-1$"

    - type: validation
      step_description: "Second item shows price $price-2$"

Conditional Logic

Optional Popup Handling

Handling popups that may or may not appear:
test:
  metadata:
    name: "Handle Optional Cookie Banner"
    platform: web

  build:
    name: "Marketing Site"

  blocks:
    - type: if
      condition: "A cookie consent banner is visible"
      then:
        - type: instructions
          step_description: "Click 'Accept All Cookies'"

    - type: instructions
      step_description: "Click 'Get Started'"

    - type: validation
      step_description: "The signup page is displayed"

Different Paths Based on State

Branching based on user state:
test:
  metadata:
    name: "Dashboard Access"
    platform: web

  build:
    name: "App"

  blocks:
    - type: if
      condition: "The user is already logged in"
      then:
        - type: validation
          step_description: "The dashboard is visible"
      else:
        - type: instructions
          step_description: "Complete the sign up flow"
        - type: validation
          step_description: "The dashboard is now visible"

Nested Conditionals

Complex conditional logic:
test:
  metadata:
    name: "Payment Method Selection"
    platform: web

  build:
    name: "Checkout App"

  blocks:
    - type: instructions
      step_description: "Proceed to payment"

    - type: if
      condition: "A saved payment method is available"
      then:
        - type: instructions
          step_description: "Select saved payment method"
      else:
        - type: instructions
          step_description: "Click 'Add New Payment Method'"

        - type: if
          condition: "Apple Pay is available"
          then:
            - type: instructions
              step_description: "Select Apple Pay"
          else:
            - type: instructions
              step_description: "Enter credit card details"

    - type: instructions
      step_description: "Complete payment"

Loops and Iteration

Load All Content

Loading paginated content:
test:
  metadata:
    name: "Load All Products"
    platform: web

  build:
    name: "E-commerce Site"

  blocks:
    - type: instructions
      step_description: "Navigate to products page"

    - type: while
      condition: "A 'Load More' button is visible"
      body:
        - type: instructions
          step_description: "Click 'Load More'"

    - type: validation
      step_description: "All products are displayed"

Dismiss Multiple Notifications

Clearing all notifications:
test:
  metadata:
    name: "Clear All Notifications"
    platform: android

  build:
    name: "Social App"

  blocks:
    - type: instructions
      step_description: "Open notifications"

    - type: while
      condition: "Notification items are present"
      body:
        - type: instructions
          step_description: "Swipe left on the first notification"

        - type: instructions
          step_description: "Tap 'Delete'"

    - type: validation
      step_description: "No notifications remain"

When Manual Navigation IS Needed

Mobile App Lifecycle Testing

Example of when close_app/open_app is appropriate:
test:
  metadata:
    name: "App State Persistence"
    platform: ios

  build:
    name: "Notes App"

  blocks:
    # App already open
    - type: instructions
      step_description: "Create a new note with text 'Test Note'"

    - type: instructions
      step_description: "Navigate to settings"

    # Test app closing and reopening
    - type: manual
      step_type: close_app

    - type: manual
      step_type: wait
      step_description: "2"

    - type: manual
      step_type: open_app

    # Verify state persisted
    - type: validation
      step_description: "App reopens to settings screen"

    - type: instructions
      step_description: "Navigate to notes list"

    - type: validation
      step_description: "Note with text 'Test Note' is visible"

Advanced Patterns

Form Submission with Validation

Complete form flow:
test:
  metadata:
    name: "Registration Form"
    platform: web

  build:
    name: "App"

  blocks:
    - type: instructions
      step_description: "Click 'Sign Up'"

    - type: instructions
      step_description: "Enter 'John Doe' in the name field"

    - type: instructions
      step_description: "Enter '[email protected]' in the email field"

    - type: instructions
      step_description: "Enter 'SecurePass123!' in the password field"

    - type: instructions
      step_description: "Enter 'SecurePass123!' in the confirm password field"

    - type: instructions
      step_description: "Check the terms and conditions checkbox"

    - type: instructions
      step_description: "Click 'Create Account'"

    - type: validation
      step_description: "Account created successfully"

    - type: validation
      step_description: "Welcome email message is shown"

Search with No Results Handling

Search flow with conditional result handling:
test:
  metadata:
    name: "Product Search"
    platform: web

  build:
    name: "E-commerce Site"

  blocks:
    - type: instructions
      step_description: "Enter a random item in the search box"

    - type: instructions
      step_description: "Click search"

    - type: if
      condition: "Search results are displayed"
      then:
        - type: validation
          step_description: "At least one product is shown"

        - type: instructions
          step_description: "Click the first result"
      else:
        - type: validation
          step_description: "No results message is displayed"

        - type: validation
          step_description: "Search suggestions are shown"

Multi-Step Checkout

Complete e-commerce checkout flow:
test:
  metadata:
    name: "Complete Checkout"
    platform: web

  build:
    name: "Shopping Site"

  blocks:
    # Product selection
    - type: instructions
      step_description: "Search for 'laptop'"

    - type: instructions
      step_description: "Click the first product"

    - type: extraction
      step_description: "The product name"
      variable_name: product-name

    - type: extraction
      step_description: "The product price"
      variable_name: product-price

    - type: instructions
      step_description: "Click 'Add to Cart'"

    # Cart review
    - type: instructions
      step_description: "Click cart icon"

    - type: validation
      step_description: "Cart contains '$product-name$'"

    - type: validation
      step_description: "Price shows $product-price$"

    - type: instructions
      step_description: "Click 'Proceed to Checkout'"

    # Shipping info
    - type: instructions
      step_description: "Enter '123 Main St' in the address field"

    - type: instructions
      step_description: "Enter 'New York' in the city field"

    - type: instructions
      step_description: "Select 'NY' from state dropdown"

    - type: instructions
      step_description: "Enter '10001' in the zip code field"

    - type: instructions
      step_description: "Click 'Continue to Payment'"

    # Payment
    - type: instructions
      step_description: "Enter '4111111111111111' in the card number field"

    - type: instructions
      step_description: "Enter '12/25' in the expiry field"

    - type: instructions
      step_description: "Enter '123' in the CVV field"

    - type: instructions
      step_description: "Click 'Place Order'"

    - type: extraction
      step_description: "The order confirmation number"
      variable_name: order-id

    - type: validation
      step_description: "Order confirmation page displays order #$order-id$"

    - type: validation
      step_description: "Product '$product-name$' is listed in the order"

Best Practices

Do NOT Start with Manual Navigation

# INCORRECT - unnecessary manual navigation
blocks:
  - type: manual
    step_type: navigate
    step_description: "https://app.example.com"  # DON'T DO THIS
  - type: instructions
    step_description: "Click login"

# CORRECT - start with action
blocks:
  - type: instructions
    step_description: "Click login"

Use Descriptive Variable Names

# INCORRECT - unclear names
- type: extraction
  step_description: "The price"
  variable_name: var1

# CORRECT - descriptive names
- type: extraction
  step_description: "The product price"
  variable_name: product-price

Validate After Important Actions

- type: instructions
  step_description: "Click 'Submit Order'"

# Always validate the result
- type: validation
  step_description: "Order confirmation is displayed"
I