Skip to content

Add Self-Healing Test Capabilities #129

Description

@jedau

Description:
Implement intelligent self-healing capabilities for tests to automatically recover from common failures.

Acceptance Criteria:

  • Auto-retry with alternative selectors when element not found
  • Selector healing: when primary selector fails, try backup selectors (id, class, text, aria-label)
  • Intelligent wait strategies: adjust wait times based on historical performance
  • Learning mechanism: track which selectors work most reliably
  • Create test/utils/self-healing.ts with healing utilities
  • Add configuration in .env for enabling/disabling self-healing
  • Document selector healing strategy in ARCHITECTURE.md
  • Add examples in WRITING-TESTS.md
  • Generate report on healed tests and selector changes

Technical Approach:

// Example implementation concept
export class SelfHealingLocator {
  async findElement(primarySelector: string, fallbacks: string[]) {
    try {
      return await page.locator(primarySelector)
    } catch {
      for (const fallback of fallbacks) {
        try {
          return await page.locator(fallback)
          // Log the healing event
        } catch {
          continue
        }
      }
      throw new Error('All selectors failed')
    }
  }
}

Benefits:

  • Reduces flaky test failures from minor DOM changes
  • Improves test maintenance by auto-adapting to UI changes
  • Provides insights into which selectors are most stable
  • Increases confidence in automated test results

References:

Metadata

Metadata

Assignees

No one assigned

    Labels

    advancedComplex, requires deep understandingenhancementNew features or test coveragetestingTest infrastructure and tools

    Projects

    Status
    TODO

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions