Puppeteer Element Handle

View as Markdown

All Element Handle methods available when using the Puppeteer driver.

Access via elementHandle after launching a Puppeteer runtime.

Every method below is a remote call. The SDK translates it into a structured step sent to a single endpoint:

POST /v1/workspaces/{workspaceId}/execute
1{
2 "runtime": "my-browser",
3 "steps": [
4 {
5 "call": "element.goto",
6 "args": ["https://example.com"]
7 }
8 ]
9}

The call field maps directly to the method name. args is a JSON array of the method’s arguments. You can batch multiple steps in one request.

Actions

click(options?)

Click the element.

1await elementHandle.click();
ParameterTypeRequiredDescription
optionsPuppeteerClickOptionsNo

Upstream docs


hover()

Hover over the element.

1await elementHandle.hover();

Upstream docs


tap()

Tap the element (for touch devices).

1await elementHandle.tap();

Upstream docs


focus()

Focus the element.

1await elementHandle.focus();

Upstream docs


type(text, options?)

Type text into the element.

1await elementHandle.type('...');
ParameterTypeRequiredDescription
textstringYes
optionsPuppeteerKeyboardTypeOptionsNo

Upstream docs


press(key, options?)

Press a key while focused on the element.

1await elementHandle.press('...');
ParameterTypeRequiredDescription
keystringYes
optionsPuppeteerKeyPressOptionsNo

Upstream docs


select(…values)

Select options in a <select> element.

1await elementHandle.select(/* string[] */);
ParameterTypeRequiredDescription
valuesstring[]Yes

Returns string[] — An array of selected option values.

Upstream docs


dragAndDrop(target, options?)

Drag and drop to another element or point.

1await elementHandle.dragAndDrop(/* target */);
ParameterTypeRequiredDescription
targetRemotePuppeteerElementHandle | PuppeteerPointYesTarget element or point to drop onto.
options{ delay?: number }No

Upstream docs


Queries

$(selector)

Query for a child element.

1await elementHandle.$('...');
ParameterTypeRequiredDescription
selectorstringYes

Returns RemotePuppeteerElementHandle \| null — The matching element or null if not found.

Upstream docs


$$(selector)

Query for all matching child elements.

1await elementHandle.$$('...');
ParameterTypeRequiredDescription
selectorstringYes

Returns RemotePuppeteerElementHandle[] — An array of matching elements.

Upstream docs


$x(expression)

Query for child elements by XPath. (Uses $$() with xpath prefix internally)

XPath queries are deprecated. Consider using CSS selectors instead.

1await elementHandle.$x('...');
ParameterTypeRequiredDescription
expressionstringYes

Returns RemotePuppeteerElementHandle[]

Upstream docs


contentFrame()

Get the content frame for iframe elements.

1await elementHandle.contentFrame();

Returns RemotePuppeteerFrame \| null — The frame or null if not an iframe.

Upstream docs


Content

getProperty(propertyName)

Get a property value.

1await elementHandle.getProperty('...');
ParameterTypeRequiredDescription
propertyNamestringYes

Returns T

Upstream docs


jsonValue()

Get the JSON value of the element.

1await elementHandle.jsonValue();

Returns T

Upstream docs


backendNodeId()

Get the backend node ID (Chrome DevTools Protocol).

This value is stable for the lifetime of the node. The SDK caches this value after the first call.

1await elementHandle.backendNodeId();

Returns number

Upstream docs


boundingBox()

Get the bounding box of the element.

1await elementHandle.boundingBox();

Returns PuppeteerBoundingBox \| null — The bounding box or null if the element is not visible.

Upstream docs


State Checks

isVisible()

Check if the element is visible.

1await elementHandle.isVisible();

Returns boolean

Upstream docs


isHidden()

Check if the element is hidden.

1await elementHandle.isHidden();

Returns boolean

Upstream docs


isIntersectingViewport(options?)

Check if the element intersects the viewport.

1await elementHandle.isIntersectingViewport();
ParameterTypeRequiredDescription
options{ threshold?: number }No

Returns boolean

Upstream docs


Waiting

waitForSelector(selector, options?)

Wait for a child element to appear.

1await elementHandle.waitForSelector('...');
ParameterTypeRequiredDescription
selectorstringYes
optionsPuppeteerWaitForSelectorOptionsNo

Returns RemotePuppeteerElementHandle \| null

Upstream docs


Screenshots & PDF

screenshot(options?)

Take a screenshot of the element.

Returns base64 string by default. If options.encoding is “binary”, the SDK converts the base64 to a Buffer.

1await elementHandle.screenshot();
ParameterTypeRequiredDescription
optionsPuppeteerScreenshotOptionsNo

Returns string \| Buffer

Upstream docs


Evaluation

evaluate(pageFunction, …args)

Evaluate a function in the context of the element.

The element is passed as the first argument to the function.

1await elementHandle.evaluate('...');
ParameterTypeRequiredDescription
pageFunctionstring | ((element: Element, ...args: unknown[]) =&gt; T | Promise&lt;T&gt;)Yes
argsunknown[]No

Returns T

Upstream docs


$eval(selector, pageFunction, …args)

Evaluate a function on the first child matching the selector.

1await elementHandle.$eval('...', '...');
ParameterTypeRequiredDescription
selectorstringYes
pageFunctionstring | ((element: Element, ...args: unknown[]) =&gt; T | Promise&lt;T&gt;)Yes
argsunknown[]No

Returns T

Upstream docs


$$eval(selector, pageFunction, …args)

Evaluate a function on all children matching the selector.

1await elementHandle.$$eval('...', '...');
ParameterTypeRequiredDescription
selectorstringYes
pageFunctionstring | ((elements: Element[], ...args: unknown[]) =&gt; T | Promise&lt;T&gt;)Yes
argsunknown[]No

Returns T

Upstream docs


Other

uploadFile(…filePaths)

Upload files to a file input element.

1await elementHandle.uploadFile(/* string[] */);
ParameterTypeRequiredDescription
filePathsstring[]Yes

Upstream docs


scrollIntoView()

Scroll the element into view.

1await elementHandle.scrollIntoView();

Upstream docs


autofill(data)

Test if the form is compatible with browser autofill. Currently supports credit card autofill in Chrome headless/headful only.

1await elementHandle.autofill(/* PuppeteerAutofillData */);
ParameterTypeRequiredDescription
dataPuppeteerAutofillDataYes

Upstream docs


boxModel()

Get the CSS box model of the element.

1await elementHandle.boxModel();

Returns PuppeteerBoxModel \| null — The box model or null if the element is not visible.

Upstream docs


clickablePoint(offset?)

Get a clickable point within the element.

1await elementHandle.clickablePoint();
ParameterTypeRequiredDescription
offsetPuppeteerOffsetNo

Returns PuppeteerPoint

Upstream docs


frame()

Get the owning frame of this element.

1elementHandle.frame();

Returns RemotePuppeteerFrame

Upstream docs


drag(target)

Drag the element to the given target.

1await elementHandle.drag(/* target */);
ParameterTypeRequiredDescription
targetPuppeteerPoint | RemotePuppeteerElementHandleYesTarget point or element to drag to.

Returns PuppeteerDragData \| void

Upstream docs


dragEnter(data?)

Dispatch a dragenter event.

Deprecated: dragenter is automatically performed during dragging.

1await elementHandle.dragEnter();
ParameterTypeRequiredDescription
dataPuppeteerDragDataNo

Upstream docs


dragOver(data?)

Dispatch a dragover event.

Deprecated: dragover is automatically performed during dragging.

1await elementHandle.dragOver();
ParameterTypeRequiredDescription
dataPuppeteerDragDataNo

Upstream docs


drop(element)

Drop the given element onto the current one.

1await elementHandle.drop(/* HandleRef */);
ParameterTypeRequiredDescription
elementRemotePuppeteerElementHandleYesElement to drop.

Upstream docs


touchStart()

Start a touch in the center of the element.

Scrolls element into view if needed.

1await elementHandle.touchStart();

Returns TouchHandle — A TouchHandle for controlling this touch point.

Upstream docs


touchMove(touch?)

Move the touch to the center of the element.

Scrolls element into view if needed.

1await elementHandle.touchMove();
ParameterTypeRequiredDescription
touch{ touchId?: string }No

Upstream docs


touchEnd()

End the first active touch.

1await elementHandle.touchEnd();

Upstream docs


toElement(tagName)

Convert to a typed element handle.

Throws if the element is not of the specified tag type. Do NOT dispose the original handle - both handles reference the same element.

1Converting to an anchor element:
2```ts
3const element = await page.$('.class-name-of-anchor');
4const anchor = await element.toElement('a');
5// anchor.href is now typed
| Parameter | Type | Required | Description |
|---|---|---|---|
| `tagName` | `K` | Yes | — |
**Returns** `RemotePuppeteerElementHandle`
[Upstream docs](https://pptr.dev/api/puppeteer.elementhandle.toelement)
---
### asLocator()
Create a Locator based on this ElementHandle.
<Note>
This does not refresh the handle if stale, but allows using locator conditions.
</Note>
```ts
elementHandle.asLocator();

Returns RemotePuppeteerLocator

Upstream docs


dispose()

Dispose of the handle, releasing it from the backend registry.

After disposal, any method calls will throw. The SDK sets the disposed flag before the RPC call to prevent race conditions.

1await elementHandle.dispose();

Upstream docs