config:
  app: com.google.android.calculator

setup:
  - terminate_app
  - launch_app
  - wait: 2s

teardown:
  - terminate_app

tests:
  - name: if_exists - Check button presence
    steps:
      # Test if_exists operator
      - if_exists: "5"
        then:
          - tap: "5"
          - verify_screen: "Display shows 5"
        else:
          - tap: "AC"

  - name: if_not_exists - Verify no error
    steps:
      - tap: "AC"
      - wait: 500ms
      # Check display is clear (no error)
      - if_not_exists: "Error"
        then:
          - verify_screen: "Clear calculator display"
        else:
          - tap: "AC"

  - name: if_all_exist - Multiple buttons present
    steps:
      # Verify all number buttons 1, 2, 3 exist
      - if_all_exist: ["1", "2", "3"]
        then:
          - verify_screen: "Number pad visible"

  - name: if_any_exist - Handle UI variations
    steps:
      # Check for + operator (might have variations)
      - if_any_exist: ["+", "plus", "add"]
        then:
          - tap: "+"
          - tap: "1"
          - tap: "="

  - name: if_screen - AI vision check
    steps:
      - tap: "AC"
      - tap: "2"
      - tap: "+"
      - tap: "2"
      - tap: "="
      # Use AI vision to verify result
      - if_screen: "Calculator display shows 4"
        then:
          - tap: "AC"
        else:
          - verify_screen: "Unexpected calculation result"

  - name: Nested conditionals - 2 levels deep
    steps:
      - tap: "AC"
      # Level 1: Check if button 5 exists
      - if_exists: "5"
        then:
          - tap: "5"
          # Level 2: Check if + operator exists
          - if_exists: "+"
            then:
              - tap: "+"
              - tap: "3"
              - tap: "="
              - verify_screen: "Display shows 8"
        else:
          - tap: "1"
