Skip to content

Action reference

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.

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

click

Clicks the element.

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

fill

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

1
$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.

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

press

Dispatches a single key.

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

check and uncheck

Tick or clear a checkbox.

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

select-option

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

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

hover

Moves the pointer over the element.

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