import type { MobilewrightDriver, SwipeDirection } from '@mobilewright/protocol'; import { type LocatorStrategy, type Role } from './query-engine.js'; import { type StepLocation } from './stackTrace.js'; export type StepFn = (title: string, fn: () => Promise, location: StepLocation | undefined) => Promise; export interface LocatorOptions { timeout?: number; pollInterval?: number; stabilityDelay?: number; /** Default timeout for expect() assertions on this locator, in ms. */ expectTimeout?: number; } export interface FilterOptions { /** Keep only elements whose subtree contains this text. */ hasText?: string | RegExp; /** Keep only elements whose subtree does NOT contain this text. */ hasNotText?: string | RegExp; /** Keep only elements that contain an element matching this locator. */ has?: Locator; /** Keep only elements that do NOT contain an element matching this locator. */ hasNot?: Locator; } export interface ScrollIntoViewOptions { /** Maximum number of swipe attempts before giving up (default: 10) */ maxSwipes?: number; /** Swipe gesture direction — 'up' swipes up (scrolls content down), 'down' swipes down (scrolls content up). Default: 'up' */ direction?: 'up' | 'down'; } export declare class Locator { protected readonly driver: MobilewrightDriver; protected readonly strategy: LocatorStrategy; protected readonly options: LocatorOptions; /** Create a root locator that searches the entire view hierarchy. */ static root(driver: MobilewrightDriver, options?: LocatorOptions): Locator; _stepFn: StepFn | null; constructor(driver: MobilewrightDriver, strategy: LocatorStrategy, options?: LocatorOptions); get expectTimeout(): number | undefined; protected _step(title: string, fn: () => Promise): Promise; getByLabel(label: string, opts?: { exact?: boolean; }): Locator; getByTestId(testId: string): Locator; getByText(text: string | RegExp, opts?: { exact?: boolean; }): Locator; getByType(type: string): Locator; getByRole(role: Role, opts?: { name?: string | RegExp; }): Locator; getByPlaceholder(placeholder: string, opts?: { exact?: boolean; }): Locator; protected child(childStrategy: LocatorStrategy): Locator; /** Build a sibling locator that shares this one's driver, options, and step fn. */ protected withStrategy(strategy: LocatorStrategy): Locator; /** Narrow this locator to elements matching the given conditions. */ filter(opts?: FilterOptions): Locator; /** Match elements that satisfy both this locator and the given locator. */ and(locator: Locator): Locator; /** Match elements that satisfy either this locator or the given locator. */ or(locator: Locator): Locator; first(): Locator; last(): Locator; nth(index: number): Locator; count(): Promise; all(): Promise; tap(opts?: { timeout?: number; }): Promise; doubleTap(opts?: { timeout?: number; }): Promise; longPress(opts?: { timeout?: number; duration?: number; }): Promise; clear(opts?: { timeout?: number; }): Promise; fill(text: string, opts?: { timeout?: number; }): Promise; /** Resolve the element, tap its center to focus/activate it, and return the node. */ private _resolveAndTap; /** Focus the element by tapping it, then clear its contents. */ private _tapAndClear; /** Read the element's current value from the latest hierarchy, '' if absent. */ private _currentValue; screenshot(opts?: { timeout?: number; }): Promise; swipe(opts: { direction: SwipeDirection; timeout?: number; }): Promise; scrollIntoViewIfNeeded(opts?: ScrollIntoViewOptions): Promise; exists(): Promise; isVisible(opts?: { timeout?: number; }): Promise; isEnabled(opts?: { timeout?: number; }): Promise; isSelected(opts?: { timeout?: number; }): Promise; isFocused(opts?: { timeout?: number; }): Promise; isChecked(opts?: { timeout?: number; }): Promise; boundingBox(opts?: { timeout?: number; }): Promise<{ x: number; y: number; width: number; height: number; }>; getText(opts?: { timeout?: number; }): Promise; getValue(opts?: { timeout?: number; }): Promise; waitFor(opts?: { state?: 'visible' | 'hidden' | 'enabled' | 'disabled'; timeout?: number; }): Promise; /** Wait for a visible node and return it. Used by getText, screenshot. */ private resolveVisible; /** Poll until the given state is satisfied. Returns the matched node (or null for hidden/disabled). */ private pollUntilState; /** Resolve to a single actionable node (visible, enabled, stable bounds) */ private resolveActionable; /** Resolve without waiting — returns null if not found */ private resolve; } export declare class LocatorError extends Error { readonly strategy: LocatorStrategy; constructor(message: string, strategy: LocatorStrategy); } //# sourceMappingURL=locator.d.ts.map