Target

This is the Target class and its API.

Target API

class Target(name: str | None = None)

A described element on a webpage.

Examples:

Target.the('"Log In" button').located_by("button:has-text('Log In')")

Target.the("toast message").located_by("//toast")

Target.the('"Pick up Milk" todo item").located_by(
    "_vue=list-item[text *= 'milk' i]"
)

Target().located_by("#enter-todo-field")
classmethod the(name: str) Self

Provide a human-readable description of the target.

located_by(locator: str) Target

Provide the Playwright locator which describes the element.

in_frame(frame_locator: str) Target

Provide the Playwright locator which describes the frame.

property target_name: str

Get the name of the Target.

Returns:

The text representation of this Target.

found_by(the_actor: Actor) Locator

Get the Playwright Locator described by this Target.

Args:

the_actor: the Actor who should find this Locator.

Returns:

The Locator which describes the element.