/** * healing-engine.ts * * Provides pure local (no AI) self-healing for failed test steps. * * When a Playwright locator fails during test execution, the HealingEngine * attempts to find an alternative working locator by trying three strategies * in order: * 1. element-context — use rich metadata stored in the Page Object's ELEMENT_CONTEXTS * 2. semantic-text — scan the page by role, text, or placeholder that matches the step description * 3. accessibility — scan aria-label attributes for a match * * If all local strategies fail, the engine returns a failure result signalling * that the caller should escalate to the AI-assisted heal_test MCP tool. * * This file is part of the execution pipeline: * Executor → FailureHandler → HealingEngine */ import { Page } from 'playwright'; import { HealingContext, HealingResult } from '../types'; /** * Attempts to recover from a failed test step without calling any AI model. * * The engine works by trying multiple locator resolution strategies and * returning the first one that actually finds an element on the live page. */ export declare class HealingEngine { private selectorEngine; /** * Try to heal a failed step by finding an alternative locator. * * @param page - The live Playwright page where the step failed. * @param ctx - Context about the failure: step description, DOM snapshot, * optional stored ElementContext metadata, and the original intent. * @returns A HealingResult describing whether healing succeeded, which locator * was found (if any), and which strategy was used. */ heal(page: Page, ctx: HealingContext): Promise; /** * Build a list of candidate locator expressions from stored ElementContext * metadata and return the first one that resolves to at least one element * on the current page. * * @param page - The live Playwright page. * @param ec - Stored element metadata: role, label, placeholder, text, testId, etc. * @returns The first working locator expression, or null if none matched. */ private healFromContext; /** * Parse a locator expression string (e.g. "page.getByRole('button', { name: /Login/i })") * and return the corresponding live Playwright Locator object. * * Supports: getByRole, getByLabel, getByPlaceholder, getByText, getByTestId, and * falls back to page.locator() for raw CSS selectors. * * @param page - The Playwright page to resolve against. * @param expr - A locator expression string as generated by the skill layer. * @returns A Playwright Locator. */ private resolveLocator; } //# sourceMappingURL=healing-engine.d.ts.map