locator

Locator

A WWW::Playwright::Locator points at one or more elements matched by a selector. Get one from Page.locator or by chaining from another locator. Playwright auto-waits for the element before each action.

Chaining

locator(Str $selector --> Locator)

Returns a locator scoped to the matches of this one.

$page.locator('body').locator('#greeting');

Actions

MethodEffect
click(--> Nil)Clicks the element.
fill(Str $value --> Nil)Replaces an input's value.
type(Str $text --> Nil)Types text one key at a time.
press(Str $key --> Nil)Dispatches a single key.
check(--> Nil)Ticks a checkbox.
uncheck(--> Nil)Clears a checkbox.
select-option(Str $value --> List)Selects an option, returns chosen values.
hover(--> Nil)Moves the pointer over the element.

See the Action reference for examples.

Queries

MethodReturns
text-content(--> Str)The element's textContent.
inner-text(--> Str)The rendered innerText.
get-attribute(Str $name)A named attribute's value.
input-value(--> Str)The current input/select value.
count(--> Int)The number of matched elements.
is-visible(--> Bool)Whether the element is visible.
is-enabled(--> Bool)Whether the element is enabled.
is-checked(--> Bool)Whether a checkbox is ticked.

See the Query reference for examples.

Auto-waiting

wait-for(Str :$state --> Nil)

Waits until the element reaches a state: attached, detached, visible, or hidden.

$page.locator('#greeting').wait-for(state => 'visible');

WWW::Playwright v0.9.1

A Raku driver for Playwright via a long-lived Node sidecar

The Camelia image is copyright 2009 by Larry Wall. "Raku" is trademark of the Yet Another Society. All rights reserved.