/** * QA360 Intelligent Selector Generator * * Generates optimal CSS selectors by adapting to the detected site profile. * Follows Testing Library best practices with configurable strategies. * * Philosophy: "The more your tests resemble the way your software is used, * the more confidence they can give you." - Kent C. Dodds */ import type { SiteAnalysis, SiteProfile } from './site-profiler.js'; /** * Selector strategy tier definition */ export interface SelectorTier { tier: number; name: string; fn: string; weight: number; } /** * Selector generation result with metadata */ export interface SelectorResult { selector: string; tier: number; type: string; weight: number; } /** * Element information for selector generation */ export interface ElementInfo { tagName?: string; id?: string; className?: string; attributes?: Record; textContent?: string; role?: string; name?: string; value?: string; type?: string; } /** * Selector strategies by site profile * * Each profile has a different priority order (tiers) for selector generation. * Higher tier = higher priority = checked first. */ declare const SELECTOR_STRATEGIES: Record; /** * Check if ID is auto-generated (NOT stable) */ export declare function isGeneratedId(id: string): boolean; /** * Check if ID is semantic (describes the PURPOSE) */ export declare function isSemanticId(id: string): boolean; /** * Check if class is a utility class (should be filtered out) */ export declare function isUtilityClass(cls: string): boolean; /** * Intelligent Selector Generator * * Adapts selector generation strategy based on detected site profile. */ export declare class IntelligentSelectorGenerator { private siteProfile; private siteAnalysis; strategy: SelectorTier[] | null; /** * Initialize the generator with site analysis */ initialize(analysis: SiteAnalysis): void; /** * Get the current site profile */ getProfile(): SiteProfile | null; /** * Get the current strategy */ getStrategy(): SelectorTier[] | null; /** * Determine site profile from analysis */ private determineProfile; /** * Log the detected profile to console */ private logProfile; /** * Generate optimal selector for an element */ generateSelector(element: ElementInfo): SelectorResult; /** * Try to generate a selector for a specific type */ private trySelector; /** * TIER 1/7 - Get test ID selector */ private getTestIdSelector; /** * TIER 2/6 - Get role + name selector (ARIA) */ private getRoleNameSelector; /** * TIER 3 - Get label selector */ private getLabelSelector; /** * TIER 4 - Get placeholder selector */ private getPlaceholderSelector; /** * TIER 5/1 - Get text selector */ private getTextSelector; /** * TIER 6/4 - Get alt text selector (images) */ private getAltTextSelector; /** * TIER 7 - Get title selector */ private getTitleSelector; /** * TIER 8/1 - Get ID selector (semantic only) */ private getIdSelector; /** * TIER 2 - Get name selector (for forms) */ private getNameSelector; /** * TIER 4 - Get value selector (submit buttons, etc.) */ private getValueSelector; /** * TIER 9/7 - Get CSS selector (MAX 2 semantic classes) */ private getCssSelector; } /** * Initialize the global generator with site analysis */ export declare function initializeSelectorGenerator(analysis: SiteAnalysis): void; /** * Generate optimal selector for an element (uses global instance) */ export declare function generateSelector(element: ElementInfo): string; /** * Generate selector with metadata (tier, type, weight) */ export declare function generateSelectorWithMetadata(element: ElementInfo): SelectorResult; /** * Get the current site profile */ export declare function getSiteProfile(): SiteProfile | null; /** * Get the current strategy */ export declare function getSelectorStrategy(): SelectorTier[] | null; export { SELECTOR_STRATEGIES };