For AI agents: a documentation index is available at /llms.txt
Skip to main content

ElementHandle

A handle to a matched element.

Note: unlike puppeteer's live ElementHandle, the property getters (innerText, outerHTML, …) return a snapshot captured when the handle was created via page.$(). They do not re-query the DOM, so they won't reflect later mutations. The action methods (click, type, hover, select) and the scoped query methods ($, $$) always operate against the live page.

Accessors​

childElementCount​

Get Signature​

get childElementCount(): number | null;

The number of direct child elements.

Returns​

number | null


className​

Get Signature​

get className(): string | null;

The element class attribute, when present.

Returns​

string | null


id​

Get Signature​

get id(): string | null;

The element id, when present.

Returns​

string | null


innerHTML​

Get Signature​

get innerHTML(): string | null;

The element's inner HTML, when returned by BrowserQL.

Returns​

string | null


innerText​

Get Signature​

get innerText(): string | null;

The element's visible text, when returned by BrowserQL.

Returns​

string | null


localName​

Get Signature​

get localName(): string | null;

The element local tag name.

Returns​

string | null


outerHTML​

Get Signature​

get outerHTML(): string | null;

The element's outer HTML, when returned by BrowserQL.

Returns​

string | null


selector​

Get Signature​

get selector(): string;

The selector used to create this handle.

Returns​

string

Methods​

$()

$(selector): Promise<ElementHandle | null>;

Query for the first descendant matching selector, scoped to this element.

Parameters​

ParameterType
selectorstring

Returns​

Promise<ElementHandle | null>


$$()​

$$(selector): Promise<ElementHandle[]>;

Query for all descendants matching selector, scoped to this element.

Parameters​

ParameterType
selectorstring

Returns​

Promise<ElementHandle[]>


click()​

click(options?): Promise<ClickResponse>;

Clicks the element using its original selector.

Parameters​

ParameterType
options?ClickOptions

Returns​

Promise<ClickResponse>


hover()​

hover(): Promise<HoverResponse>;

Hovers the element using its original selector.

Returns​

Promise<HoverResponse>


screenshot()​

screenshot(options?): Promise<Uint8Array<ArrayBufferLike>>;

Captures a screenshot of the element.

Parameters​

ParameterType
options?{ path?: string; }
options.path?string

Returns​

Promise<Uint8Array<ArrayBufferLike>>


select()​

select(...values): Promise<SelectResponse>;

Select option(s) on this element (it must be a <select>).

Parameters​

ParameterType
...valuesstring[]

Returns​

Promise<SelectResponse>


textContent()​

textContent(): Promise<string>;

Reads the element's current text content.

Returns​

Promise<string>


type()​

type(text, options?): Promise<TypeResponse>;

Types text into the element using its original selector.

Parameters​

ParameterType
textstring
options?TypeOptions

Returns​

Promise<TypeResponse>

Was this page helpful?