webdriverio
Version:
Next-gen browser and mobile automation test framework for Node.js
134 lines • 7.15 kB
TypeScript
import { type remote } from 'webdriver';
import type { ElementReference } from '@wdio/protocols';
import { type ShadowRootManager } from '../session/shadowRoot.js';
import type { Selector, ParsedCSSValue, CustomLocatorReturnValue } from '../types.js';
declare global {
interface Window {
__wdio_element: Record<string, HTMLElement>;
}
}
/**
* enhances objects with element commands
*/
export declare const getPrototype: (scope: "browser" | "element") => Record<string | symbol, PropertyDescriptor>;
/**
* get element id from WebDriver response
* @param {?Object|undefined} res body object from response or null
* @return {?string} element id or null if element couldn't be found
*/
export declare const getElementFromResponse: (res?: ElementReference) => string | null;
/**
* parse css values to a better format
* @param {string} cssPropertyValue result of WebDriver call
* @param {string} cssProperty name of css property to parse
* @return {object} parsed css property
*/
export declare function parseCSS(cssPropertyValue: string, cssProperty?: string): ParsedCSSValue;
/**
* check for unicode character or split string into literals
* @param {string} value text
* @return {Array} set of characters or unicode symbols
*/
export declare function checkUnicode(value: string): string[];
export declare function isElement(o: Selector): boolean | "";
export declare function isStaleElementError(err: Error): boolean;
/**
* A stale element error that the element middleware handles: it finds the element again and
* runs the command again. The "element wasn't found" error of a wait (an element that was not
* found again, or never found) is not one, also when its message has that text (a selector like
* `[data-error="stale element reference"]`).
*/
export declare function isStaleElementToFindAgain(err: unknown): err is Error;
/**
* handle promise result (resolved or rejected promises)
* @param handle browsing context
* @param shadowRootManager instance of ShadowRootManager
* @param shadowRootId shadow root id that was inspected
* @returns a function to handle the result of a shadow root inspection
*/
export declare function elementPromiseHandler<T extends object>(handle: string, shadowRootManager: ShadowRootManager, shadowRootId?: string): (el: T | Error) => T | undefined;
export declare function transformClassicToBidiSelector(using: string, value: string): remote.BrowsingContextLocator;
/**
* Parallel look up of a selector within multiple shadow roots
* @param this WebdriverIO Browser or Element instance
* @param selector selector to look up
* @param isMulti set to true if you call from `$$` command
* @returns a list of shadow root ids with their corresponding matches or undefined if not found
*/
export declare function findDeepElement(this: WebdriverIO.Browser | WebdriverIO.Element, selector: Selector): Promise<ElementReference | undefined>;
/**
* Parallel look up of a selector within multiple shadow roots
* @param this WebdriverIO Browser or Element instance
* @param selector selector to look up
* @param isMulti set to true if you call from `$$` command
* @returns a list of shadow root ids with their corresponding matches or undefined if not found
*/
export declare function findDeepElements(this: WebdriverIO.Browser | WebdriverIO.Element, selector: Selector): Promise<ElementReference[]>;
/**
* build a selector-type-specific "element not found" error, mirroring the
* messages `findElement` produces below for each selector shape. Shared with
* `findStrictElement` (strictMode.ts) so a zero-match strict `$` surfaces the
* same level of detail as the non-strict lookup instead of a generic message.
*/
export declare function buildNotFoundError(selector: Selector): Error;
/**
* logic to find an element
* Note: the order of if statements matters
*/
export declare function findElement(this: WebdriverIO.Browser | WebdriverIO.Element, selector: Selector): Promise<Error | ElementReference | undefined>;
/**
* logic to find a elements
*/
export declare function findElements(this: WebdriverIO.Browser | WebdriverIO.Element, selector: Selector): Promise<ElementReference[]>;
/**
* Strip an element down to its W3C element reference. A chainable `$()` is not
* loaded yet, so it is not stripped (see `@wdio/utils` `kind.ts`).
*/
export declare function verifyArgsAndStripIfElement(args: unknown): unknown;
/**
* getElementRect
*/
export declare function getElementRect(scope: WebdriverIO.Element): Promise<{
x: number;
y: number;
width: number;
height: number;
}>;
/**
* check if urls are valid and fix them if necessary
* @param {string} url url to navigate to
* @param {Boolean} [retryCheck=false] true if an url was already check and still failed with fix applied
* @return {string} fixed url
*/
export declare function validateUrl(url: string, origError?: Error): string;
export declare function hasElementId(element: WebdriverIO.Element): Promise<boolean>;
export declare function addLocatorStrategyHandler(scope: WebdriverIO.Browser | WebdriverIO.MultiRemoteBrowser): (name: string, func: (selector: string, root?: HTMLElement) => CustomLocatorReturnValue) => void;
/**
* Enhance elements array with data required to refetch it
* @param {object[]} elements elements
* @param {object} parent element or browser
* @param {string|Function} selector string or function, or strategy name for `custom$$`
* @param {string} foundWith name of the command elements were found with, ex `$$`, `react$$`, etc
* @param {Array} props additional properties required to fetch elements again
* @returns {object[]} elements
*/
export declare function enhanceElementsArray(elements: WebdriverIO.Element[], parent: WebdriverIO.Browser | WebdriverIO.Element, selector: Selector | ElementReference[] | WebdriverIO.Element[], foundWith?: string, props?: unknown[]): WebdriverIO.ElementArray;
/**
* On a multi-remote browser every entry is a `MultiRemoteElement`, so the array
* that comes back is a `MultiRemoteElementArray`. The body is the same; only the
* element and parent types differ.
*/
export declare function enhanceElementsArray(elements: WebdriverIO.MultiRemoteElement[], parent: WebdriverIO.MultiRemoteBrowser | WebdriverIO.MultiRemoteElement, selector: Selector, foundWith?: string, props?: unknown[]): WebdriverIO.MultiRemoteElementArray;
/**
* is protocol stub
* @param {string} automationProtocol
*/
export declare const isStub: (automationProtocol?: string) => automationProtocol is "./protocol-stub.js";
/**
* compare if an object (`base`) contains the same values as another object (`match`)
* @param {object} base object to compare to
* @param {object} match object that needs to match thebase
*/
export declare const containsHeaderObject: (base: Record<string, string>, match: Record<string, string>) => boolean;
export declare function createFunctionDeclarationFromString(userScript: Function | string): string;
//# sourceMappingURL=index.d.ts.map