UNPKG

@serenity-js/web

Version:

Serenity/JS Screenplay Pattern library offering a flexible, web driver-agnostic approach for interacting with web-based user interfaces and components, suitable for various testing contexts

48 lines 2.75 kB
import util from 'node:util'; import type { PageElement } from './PageElement'; import { RootLocator } from './RootLocator'; import { ByCss, type Selector } from './selectors'; /** * [`Locator`](https://serenity-js.org/api/web/class/Locator/) uses a [`Selector`](https://serenity-js.org/api/web/class/Selector/) to locate a [`PageElement`](https://serenity-js.org/api/web/class/PageElement/) or [`PageElement`](https://serenity-js.org/api/web/class/PageElements/) * within the [`Page`](https://serenity-js.org/api/web/class/Page/). * * ## Learn more * - [`RootLocator`](https://serenity-js.org/api/web/class/RootLocator/) * - [`Page.locate`](https://serenity-js.org/api/web/class/Page/#locate) * - [`PageElement`](https://serenity-js.org/api/web/class/PageElement/) * - [`PageElement`](https://serenity-js.org/api/web/class/PageElements/) * * @group Models */ export declare abstract class Locator<Native_Element_Type, Native_Selector_Type = any> extends RootLocator<Native_Element_Type> { protected readonly parent: RootLocator<Native_Element_Type>; readonly selector: Selector; protected constructor(parent: RootLocator<Native_Element_Type>, selector: Selector); abstract nativeElement(): Promise<Native_Element_Type>; abstract allNativeElements(): Promise<Array<Native_Element_Type>>; switchToFrame(element: Native_Element_Type): Promise<void>; switchToParentFrame(): Promise<void>; switchToMainFrame(): Promise<void>; protected abstract nativeSelector(): Native_Selector_Type; abstract of(parent: RootLocator<Native_Element_Type>): Locator<Native_Element_Type>; abstract closestTo(child: Locator<Native_Element_Type>): Locator<Native_Element_Type>; abstract locate(child: Locator<Native_Element_Type>): Locator<Native_Element_Type>; /** * Expresses [`ByCss`](https://serenity-js.org/api/web/class/ByCss/), [`ById`](https://serenity-js.org/api/web/class/ById/), or [`ByTagName`](https://serenity-js.org/api/web/class/ByTagName/) as a [`ByCss`](https://serenity-js.org/api/web/class/ByCss/) selector. * * @throws LogicError * if the `selector` can't be expressed as [`ByCss`](https://serenity-js.org/api/web/class/ByCss/) * * @param selector * @protected */ protected asCssSelector(selector: Selector): ByCss; abstract element(): PageElement<Native_Element_Type>; abstract allElements(): Promise<Array<PageElement<Native_Element_Type>>>; toString(): string; /** * Custom [Node.js inspection method](https://nodejs.org/api/util.html#utilinspectcustom). */ [util.inspect.custom]: (depth: number, options: util.InspectOptionsStylized, inspect: typeof util.inspect) => string; } //# sourceMappingURL=Locator.d.ts.map