import type { Page } from '@playwright/test'; import type { Rect } from './types.js'; export type TextQuery = string | RegExp; export interface WordBox { text: string; confidence: number; x: number; y: number; width: number; height: number; } export interface TextMatch { location: Rect; confidence: number; text: string; } /** * Find all matches for a query in a flat list of word boxes. * For string queries, tries every consecutive window of N words (N = word count of query). * For regex queries, tries every window of 1–4 words. */ export declare function findAllMatches(words: WordBox[], query: TextQuery): TextMatch[]; /** OCR word extraction from the live page screenshot. */ export declare function extractWords(page: Page, shotDir: string, screenName: string, unhover?: boolean): Promise<{ words: WordBox[]; }>; export type TextElementOptions = { timeout?: number; }; /** * A lightweight element located by visible text via OCR. * Returned by `ScreenResult.getByText()` and `ScreenResult.getAllByText()`. * Supports click, visibility assertions, and text assertions. * Does not support fill/toHaveValue — use a registered element for inputs. */ export declare class TextElement { private match; private query; private page?; private shotDir?; private screenName?; private unhover?; constructor(match: TextMatch, query: TextQuery, page?: Page | undefined, shotDir?: string | undefined, screenName?: string | undefined, unhover?: boolean | undefined); /** The bounding rect of the matched text in screen coordinates. */ bounds(): Rect; /** The raw OCR text that was matched. */ text(): string; /** Click the matched text region using the configured ClickStrategy. */ click(): Promise; /** * Assert the text is visible on screen. * When bound to a live page, polls until the text appears or timeout expires. */ toBeVisible(options?: TextElementOptions): Promise; /** * Assert the text is not visible on screen. */ toBeHidden(options?: TextElementOptions): Promise; /** * Assert the matched OCR text equals or matches expected. */ toHaveText(expected: string | RegExp, options?: TextElementOptions): Promise; /** * Wait until this text is visible on screen. * Equivalent to toBeVisible() — exists for ergonomic parity with ScreenElement.waitFor(). */ waitFor(options?: TextElementOptions): Promise; private pollUntil; } //# sourceMappingURL=text-element.d.ts.map