donobu
Version:
Create browser automations with an LLM agent and replay them as Playwright scripts.
25 lines • 1.12 kB
TypeScript
import type { Locator, Page } from 'playwright-core';
import type { GptClient } from '../../../clients/GptClient';
import type { LocateResult } from './locateTypes';
/**
* Resolve a natural-language element description to a Playwright {@link Locator}.
*
* 1. Captures a viewport screenshot + pruned DOM snapshot.
* 2. Asks the LLM to return a structured {@link LocateResult}.
* 3. Builds a {@link Locator} and counts matches.
* - 1 match → done.
* - 2–{@link DISAMBIGUATE_THRESHOLD} matches → shows snippets, LLM picks one, appends `.nth(n)`.
* - 0 or >{@link DISAMBIGUATE_THRESHOLD} → retries once with feedback.
* 4. Throws {@link LocateException} if resolution fails after retry.
*
* Returns both the Locator and the underlying {@link LocateResult} so
* callers can cache the result for deterministic replay.
*/
export declare function locateElement(page: Page, description: string, gptClient: GptClient, options?: {
signal?: AbortSignal;
envData?: Record<string, string>;
}): Promise<{
locator: Locator;
result: LocateResult;
}>;
//# sourceMappingURL=locateElement.d.ts.map