/** * yaml-executor * * Executes a TestYaml definition directly using Playwright — * no generated .spec.ts file required. * * A TestYaml is a portable, self-describing test definition that contains * all the information needed to run a test: locators (primary + ordered fallbacks), * actions, inline assertions, wait states, and screenshot instructions. It is * generated alongside the .spec.ts file during pwpilot_save_test and can * be re-run independently via the pwpilot_run_yaml MCP tool. * * Features: * - Resolves locators in priority order (primary → fallbacks) * - Self-heals: on locator failure, tries fallbackLocators before reporting failure * - continueOnFailure: collects all failures, never aborts mid-test * - screenshotOnFailure: captures PNG at failure point * - Evaluates inline assertions after each step * * Role in the overall flow: * pwpilot_run_yaml MCP tool → YamlExecutor.runFromFile() → YamlExecutionReport */ import { TestYaml, YamlExecutionReport } from '../types'; /** * Executes TestYaml definitions directly through Playwright without needing * a generated .spec.ts file. Supports self-healing via fallback locators. */ export declare class YamlExecutor { /** * Load a YAML file from disk and execute it. * * @param yamlPath - Absolute path to the .yaml test definition file. * @param artifactsDir - Base directory for screenshots and execution reports. * @returns A full YamlExecutionReport with per-step results and overall status. */ runFromFile(yamlPath: string, artifactsDir: string): Promise; /** * Execute a TestYaml object directly (no file I/O needed for the test definition). * * Launches a Chromium browser, runs each step in order, collects results, and * writes an execution report JSON file to the artifacts directory. * * @param test - The parsed TestYaml definition to execute. * @param yamlPath - Original path of the YAML file (recorded in the report). * @param artifactsDir - Base directory for screenshots and execution reports. * @returns A YamlExecutionReport summarising all step outcomes. */ run(test: TestYaml, yamlPath: string, artifactsDir: string): Promise; /** * Execute a single YamlStep and return its result. * * Handles all action types (navigate, click, fill, select, check, uncheck, * hover, scroll, wait, screenshot, assert, pressKey) and runs any inline * assertion after the action completes. * * On failure, captures a screenshot if configured and marks the step as failed. * * @param step - The YAML step definition to execute. * @param page - The active Playwright page. * @param screenshotsDir - Directory where failure screenshots are written. * @param config - Test-level configuration (timeouts, screenshot policy, etc.). * @returns A YamlStepResult with status, timing, and optional screenshot path. */ private executeStep; /** * Dispatch a concrete Playwright action based on the step's action type. * * Handles: click, fill, select, check, uncheck, hover, scroll. * After the main action, waits for the specified load state if step.waitFor is set. * * @param step - The step whose action should be performed. * @param locator - The resolved Playwright Locator to act on. * @param page - The active Playwright page (needed for post-action waits). * @param timeout - Maximum milliseconds to wait for each action to complete. */ private performAction; /** * Resolve a step's primary locator, then try fallbacks if the primary fails. * * This is the self-healing mechanism for YAML-based execution: each step can * declare an ordered list of fallbackLocators that are tried automatically * when the primary fails to find an element. * * @param step - The YAML step containing the primary locator and optional fallbacks. * @param page - The active Playwright page. * @param timeout - Timeout in ms for each locator wait attempt. * @returns The resolved Locator, a flag indicating whether healing occurred, * and a human-readable label for the locator that was used. * @throws Error if neither the primary nor any fallback resolves to an attached element. */ private resolveLocator; /** * Convert a YamlLocator (strategy + value + options) into a live Playwright Locator. * * @param page - The Playwright page to build the locator against. * @param loc - The YAML locator definition specifying strategy and value. * @returns A Playwright Locator ready for interaction or waiting. */ private buildLocator; /** * Produce a human-readable label for a YamlLocator, e.g. "getByRole('button', {"name":"Login"})". * * @param loc - The YamlLocator to describe. * @returns A readable string representation of the locator. */ private locatorLabel; /** * Evaluate a YamlAssertion against the current page state using Playwright's * expect API. Throws if the assertion is not satisfied within the timeout. * * Supported assertion types: visible, hidden, text, url, title, enabled, checked, * count, attribute. * * @param assertion - The YAML assertion definition to evaluate. * @param page - The active Playwright page. * @param timeout - Maximum milliseconds to wait for the assertion to pass. * @throws Error if the assertion type requires a locator but none is provided, * or if the assertion itself fails. */ private evaluateAssertion; } export declare const yamlExecutor: YamlExecutor; //# sourceMappingURL=yaml-executor.d.ts.map