puppeteer/website/versioned_docs/version-22.10.0/api/puppeteer.locator.md
release-please[bot] d963fcdd80
chore: release main (#12456)
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
2024-05-24 07:26:52 +00:00

3.7 KiB

sidebar_label
Locator

Locator class

Locators describe a strategy of locating objects and performing an action on them. If the action fails because the object is not ready for the action, the whole operation is retried. Various preconditions for a successful action are checked automatically.

Signature:

export declare abstract class Locator<T> extends EventEmitter<LocatorEvents>

Extends: EventEmitter<LocatorEvents>

Properties

Property

Modifiers

Type

Description

_

optional

T

Used for nominally typing Locator.

timeout

readonly

number

Methods

Method

Modifiers

Description

click(this, options)

clone()

Clones the locator.

fill(this, value, options)

Fills out the input identified by the locator using the provided value. The type of the input is determined at runtime and the appropriate fill-out method is chosen based on the type. contenteditable, selector, inputs are supported.

filter(predicate)

Creates an expectation that is evaluated against located values.

If the expectations do not match, then the locator will retry.

hover(this, options)

map(mapper)

Maps the locator using the provided mapper.

race(locators)

static

Creates a race between multiple locators but ensures that only a single one acts.

scroll(this, options)

setEnsureElementIsInTheViewport(this, value)

setTimeout(timeout)

setVisibility(this, visibility)

setWaitForEnabled(this, value)

setWaitForStableBoundingBox(this, value)

wait(options)

Waits for the locator to get the serialized value from the page.

Note this requires the value to be JSON-serializable.

waitHandle(options)

Waits for the locator to get a handle from the page.