Actions

Actions run against a Locator. Get one from $page.locator($selector), then call an action on it. Playwright auto-waits for the element to be actionable before each action.

my $page = $context.new-page;
$page.goto('file:///path/to/hello.html');

click#

Clicks the element.

$page.locator('#go').click;

fill#

Sets the value of an input, replacing any existing value.

$page.locator('#name').fill('Ada');

type#

Types text one key at a time, appending to the current value. Use fill to replace; use type when per-keystroke events matter.

$page.locator('#name').type('Hi');

press#

Dispatches a single key.

$page.locator('#name').press('Enter');

check and uncheck#

Tick or clear a checkbox.

$page.locator('#agree').check;
$page.locator('#agree').uncheck;

select-option#

Selects an option in a <select> by value and returns the chosen values.

my @selected = $page.locator('#color').select-option('green');   # ('green',)

hover#

Moves the pointer over the element.

$page.locator('#hoverable').hover;