/** * Semantic Selector Utilities * * Extracts semantic (ARIA role-based) selectors from Playwright elements. * These selectors are more resilient to DOM structure changes than CSS selectors. */ import type { Page, ElementHandle, Locator } from 'playwright'; import type { SemanticSelector } from '../types/index.js'; /** * Extract semantic selector from a Playwright locator */ export declare function extractSemanticSelectorFromLocator(locator: Locator): Promise; /** * Extract semantic selector from a Playwright element (deprecated, use extractSemanticSelectorFromLocator) */ export declare function extractSemanticSelector(element: ElementHandle): Promise; /** * Extract semantic selector from a CSS selector on a page */ export declare function extractSemanticSelectorFromCSS(page: Page, cssSelector: string): Promise; /** * Create a Playwright locator from a semantic selector */ export declare function createLocatorFromSemantic(page: Page, semantic: SemanticSelector): Locator; /** * Try to find an element using semantic selector, with CSS fallback */ export declare function findElement(page: Page, cssSelector: string, semanticSelector?: SemanticSelector, preferSemantic?: boolean): Promise; /** * Format semantic selector as a readable string */ export declare function formatSemanticSelector(semantic: SemanticSelector): string; /** * Options for enhanced element finding with vision fallback */ export interface FindElementWithVisionOptions { /** CSS selector to try first */ cssSelector: string; /** Semantic selector for ARIA-based matching */ semanticSelector?: SemanticSelector; /** Natural language description for vision fallback */ elementDescription?: string; /** Whether to prefer semantic selector over CSS */ preferSemantic?: boolean; /** Whether to enable vision fallback */ enableVision?: boolean; /** Element type hint for vision matching */ elementType?: 'button' | 'link' | 'input' | 'text' | 'image' | 'checkbox' | 'radio' | 'dropdown' | 'other'; } /** * Result of enhanced element finding */ export interface FindElementWithVisionResult { /** The found element, or null if not found */ element: ElementHandle | null; /** Method used to find the element */ method: 'css' | 'semantic' | 'vision' | null; /** Confidence score (1.0 for CSS/semantic, vision-provided for vision) */ confidence: number; /** Whether vision was used */ usedVision: boolean; /** Click coordinates if vision was used */ clickCoordinates?: { x: number; y: number; }; /** Suggested selector from vision analysis */ suggestedSelector?: string; } /** * Try to find an element using tiered approach: * 1. CSS Selector (fastest) * 2. Semantic/ARIA Selector (resilient to DOM changes) * 3. Vision Matcher (handles dynamic/complex UIs) */ export declare function findElementWithVision(page: Page, options: FindElementWithVisionOptions): Promise; //# sourceMappingURL=semantic-selector.d.ts.map