browser-use-typescript
Version:
A TypeScript-based browser automation framework
107 lines (106 loc) • 3.47 kB
TypeScript
import { DOMElementNode } from "../domTypes/domClass";
/**
* Hash of the dom element to be used as a unique identifier
*/
export declare class HashedDomElement {
branchPathHash: string;
attributesHash: string;
xpathHash: string;
constructor(branchPathHash: string, attributesHash: string, xpathHash: string);
}
/**
* Represents a set of coordinates
*/
export declare class Coordinates {
x: number;
y: number;
constructor(x: number, y: number);
}
/**
* Represents a set of coordinates for an element
*/
export declare class CoordinateSet {
topLeft: Coordinates;
topRight: Coordinates;
bottomLeft: Coordinates;
bottomRight: Coordinates;
center: Coordinates;
width: number;
height: number;
constructor(topLeft: Coordinates, topRight: Coordinates, bottomLeft: Coordinates, bottomRight: Coordinates, center: Coordinates, width: number, height: number);
}
/**
* Represents information about the viewport
*/
export declare class ViewportInfo {
scrollX?: number;
scrollY?: number;
width: number;
height: number;
constructor(width: number, height: number, scrollX?: number, scrollY?: number);
}
/**
* Represents a DOM history element
*/
export declare class DOMHistoryElement {
tagName: string;
xpath: string;
highlightIndex?: number | null;
entireParentBranchPath: string[];
attributes: Record<string, string>;
shadowRoot: boolean;
cssSelector?: string;
pageCoordinates?: CoordinateSet;
viewportCoordinates?: CoordinateSet;
viewportInfo?: ViewportInfo;
constructor(tagName: string, xpath: string, highlightIndex: number | undefined, entireParentBranchPath: string[], attributes: Record<string, string>, shadowRoot?: boolean, cssSelector?: string, pageCoordinates?: CoordinateSet, viewportCoordinates?: CoordinateSet, viewportInfo?: ViewportInfo);
/**
* Converts the DOM history element to a dictionary
*/
toDict(): Record<string, any>;
}
/**
* Processor for the DOM history tree
*/
export declare class HistoryTreeProcessor {
/**
* Converts a DOM element to a DOM history element
*/
static convertDomElementToHistoryElement(domElement: DOMElementNode): Promise<DOMHistoryElement>;
/**
* Finds a DOM history element in the DOM tree
*/
static findHistoryElementInTree(domHistoryElement: DOMHistoryElement, tree: DOMElementNode): DOMElementNode | undefined;
/**
* Compares a DOM history element with a DOM element
*/
static compareHistoryElementAndDomElement(domHistoryElement: DOMHistoryElement, domElement: DOMElementNode): boolean;
/**
* Hashes a DOM history element
*/
static hashDomHistoryElement(domHistoryElement: DOMHistoryElement): HashedDomElement;
/**
* Hashes a DOM element
*/
static hashDomElement(domElement: DOMElementNode): HashedDomElement;
/**
* Gets the parent branch path of a DOM element
*/
static getParentBranchPath(domElement: DOMElementNode): string[];
/**
* Hashes a parent branch path
*/
static parentBranchPathHash(parentBranchPath: string[]): string;
/**
* Hashes a set of attributes
*/
static attributesHash(attributes: Record<string, string>): string;
/**
* Hashes an XPath
*/
static xpathHash(xpath: string): string;
/**
* Hashes the text of a DOM element
*/
static textHash(domElement: DOMElementNode): string;
}