UNPKG

webdriverio

Version:

Next-gen browser and mobile automation test framework for Node.js

59 lines • 2.56 kB
import type { ElementReference } from '@wdio/protocols'; import type { Selector } from '../types.js'; /** * A plain element or a multi-remote element. Both travel in the same list * implementation; the public type (`ElementArray` or `MultiRemoteElementArray`) * is chosen by the command that created it. */ type ElementList = Array<WebdriverIO.Element | WebdriverIO.MultiRemoteElement>; /** * Metadata carried by every element list returned from `$$`, `custom$$`, * `react$$` and `shadow$$`. Callers may mutate `parent` while the list is * still loading (the fetch sometimes discovers a more accurate parent). */ interface ElementArrayMetadata { /** * A list of elements (`$$([elemA, elemB])`) is normalized to one selector * when every element shares it, otherwise the list has no selector. */ selector?: Selector | WebdriverIO.Element[] | ElementReference[] | HTMLElement[]; foundWith: string; parent?: WebdriverIO.Element | WebdriverIO.Browser | WebdriverIO.MultiRemoteBrowser | WebdriverIO.MultiRemoteElement | WebdriverIO.BrowsingContext; props: unknown[]; isMultiRemote?: boolean; /** * Original queries refetch an out-of-range index. Derived lists (a `slice` * or a `filter`) must not: their bounds are not the query's bounds. */ refetch?: boolean; /** * Builds one multi-remote element from one element per instance, in the * instance order of `parent`. Set by a multi-remote `$$`. */ wrapMultiRemote?: (elements: unknown[]) => WebdriverIO.MultiRemoteElement; } /** * Element list returned by `$$` and the other multi-element queries. * * The list is a real array (`Array.isArray` is true) and a thenable until the * query finishes, so both of these work: * * ```ts * const elems = await $$('div') * for await (const el of $$('div')) { * // ... * } * ``` * * Async array helpers (`map`, `filter`, `find`, and their `*Series` variants) * resolve the list themselves. Index access before the list has resolved * returns a chainable element. After it has resolved, an index past the end of * an original query still waits and refetches. A slice or a filter does not. * `.at()` truncates its index the same way `Array.prototype.at` does. */ export declare const ElementArray: { fromAsyncCallback(loader: () => Promise<ElementList>, metadata: ElementArrayMetadata): WebdriverIO.ElementArray; fromResolved(elements: ElementList, metadata: ElementArrayMetadata): WebdriverIO.ElementArray; }; export {}; //# sourceMappingURL=array.d.ts.map