UNPKG

donobu

Version:

Create browser automations with an LLM agent and replay them as Playwright scripts.

105 lines 4.43 kB
import type { Locator } from 'playwright-core'; import type { z } from 'zod/v4'; import type { FakerDataType } from '../../tools/InputFakerTool'; import type { SelectorBasedSchema } from '../../tools/ReplayableInteraction'; import type { DonobuExtendedPage } from './DonobuExtendedPage'; /** * Action-centric facade produced by {@link DonobuExtendedPage.find}. A smart selector captures a * prioritized list of CSS/XPath selectors (plus an optional frame selector). Every method listed * below automatically attempts the selectors in order, promotes the first unique locator Playwright * can resolve, and fails over to progressively broader selectors whenever an element is missing, * detached, or otherwise unusable. */ export interface SmartSelector { /** * Choose <option> values for a particular <select> HTML element. */ selectOption(optionValues: string[]): Promise<void>; /** * Click an element on a webpage. */ click(button?: 'left' | 'right' | 'middle'): Promise<void>; /** * Double-click an element on a webpage. */ dblclick(): Promise<void>; /** * Hover the mouse over a specified element on a webpage. */ hover(): Promise<void>; /** * Create a new randomized email address based on a given email and inputs it to a specific input text field. * For example if passed "foo@gmail.com", this tool will create "foo+SOMETHING_RANDOM@gmail.com", where * SOMETHING_RANDOM is a random string of characters safe for use in an email address, and input it in the * specified text field. * * Returns the randomized email address used. * * NOTE: 'options.finalizeWithSubmit' is deprecated (use 'options.submit' instead). */ inputRandomizedEmailAddress(baseEmail: string, options?: { submit?: boolean; finalizeWithSubmit?: boolean; }): Promise<string>; /** * Input text to a webpage's text input box. * * NOTE: 'options.finalizeWithSubmit' is deprecated (use 'options.submit' instead). */ inputText(text: string, options?: { append?: boolean; submit?: boolean; finalizeWithSubmit?: boolean; }): Promise<void>; /** * Press a single key. Note that if there is existing text in the element, it is appended rather than cleared. * * Generally, prefer using the 'inputText' tool instead as it automatically clears existing text * and it allows the input of multiple characters at a time. The only advantage this tool has is * that it allows the passing of control keys like "Tab", "Backspace", etc. */ pressKey(key: string): Promise<void>; /** * Scroll the given element. */ scroll(direction: 'UP' | 'DOWN' | 'LEFT' | 'RIGHT', options?: { maxScroll?: boolean; }): Promise<void>; /** * Waits for one of the candidate locators to satisfy the requested state. * Mirrors {@link Locator.waitFor}: resolves with the locator that passed * the check or throws a Playwright `TimeoutError` when none do before the * timeout elapses. */ waitFor(options?: Parameters<Locator['waitFor']>[0]): Promise<Locator>; } export declare class SmartSelectorImpl implements SmartSelector { page: DonobuExtendedPage; selector: z.infer<typeof SelectorBasedSchema.shape.selector>; constructor(page: DonobuExtendedPage, selector: z.infer<typeof SelectorBasedSchema.shape.selector>); selectOption(optionValues: string[]): Promise<void>; dblclick(): Promise<void>; click(button?: 'left' | 'right' | 'middle'): Promise<void>; hover(): Promise<void>; inputRandomizedEmailAddress(baseEmail: string, options?: { submit?: boolean; finalizeWithSubmit?: boolean; }): Promise<string>; inputText(text: string, options?: { append?: boolean; submit?: boolean; finalizeWithSubmit?: boolean; }): Promise<void>; inputFaker(dataType: FakerDataType, options?: { append?: boolean; submit?: boolean; finalizeWithSubmit?: boolean; }): Promise<void>; pressKey(key: string): Promise<void>; scroll(direction: 'UP' | 'DOWN' | 'LEFT' | 'RIGHT', options?: { maxScroll?: boolean; }): Promise<void>; waitFor(options?: Parameters<Locator['waitFor']>[0]): Promise<Locator>; private getLocatorCandidates; } //# sourceMappingURL=SmartSelector.d.ts.map