UNPKG

@focusconsulting/auto-a11y

Version:

A powerful tool that combines AI with accessibility-first element selection for Playwright tests

62 lines (61 loc) 2.21 kB
import { Page, Locator, TestInfo } from "@playwright/test"; export declare class A11yAILocator { private page; private ollama; private anthropic; private openai; private googleAI; private model; private aiProvider; private useSimplifiedHtml; private snapshotFilePath; private cachedBodyContent; private lastHtml; private snapshotManager; private testInstance; constructor(page: Page, testInfo: TestInfo, options: { model?: string; provider: "ollama" | "anthropic" | "openai" | "gemini" | "deepseek" | "bedrock"; baseUrl?: string; snapshotFilePath?: string; apiKey?: string; timeout?: number; testInstance?: any; useSimplifiedHtml?: boolean; }); /** * Creates a locator using AI to determine the best Testing Library query * @param description Human description of the element to find * @returns Playwright Locator for the element */ locate(description: string): Promise<Locator>; /** * Attempts to locate an element using simplified HTML when the main approach times out * @param description The element description * @param html The full HTML content * @returns Object containing query name and parameters */ private locateWithSimplifiedHTML; /** * Executes a prompt against the configured AI provider * @param prompt The prompt to send to the AI * @param options Additional options for the AI request * @returns The AI response as a string */ private executePrompt; /** * Executes the appropriate Testing Library query based on the AI suggestion * @param queryName The name of the Testing Library query * @param params The parameters for the query * @returns Playwright Locator */ private executeTestingLibraryQuery; } export declare function createA11yAILocator(page: Page, testInfo: TestInfo, testInstance: any, options: { model?: string; provider: "ollama" | "anthropic" | "openai" | "gemini" | "deepseek" | "bedrock"; baseUrl?: string; snapshotFilePath?: string; apiKey?: string; useSimplifiedHtml?: boolean; }): A11yAILocator;