Skip to main content
Locator actions methods for the Playwright driver.

click

Clicks on the element.
Waits for actionability checks, scrolls element into view, and uses Page.mouse to click in the center of the element.
Upstream docs
options
PlaywrightClickOptions
await locator.click();

dblclick

Double-clicks on the element.
Performs two clicks with a short delay, simulating a native double-click. Waits for actionability checks before performing the action.
Upstream docs
options
PlaywrightDblclickOptions
await locator.dblclick();

fill

Fills an input or textarea element with the specified value.
This method waits for actionability checks, focuses the element, fills it, and triggers an input event. It clears the existing value before filling. Works with <input>, <textarea>, and [contenteditable] elements.
Upstream docs
value
string
required
Value to fill in
options
PlaywrightFillOptions
await locator.fill('...');

clear

Clears the input field.
Waits for actionability checks, focuses the element, clears it, and triggers an input event.
Upstream docs
options
PlaywrightClearOptions
await locator.clear();

press

Presses a single key or key combination.
Focuses the element, then uses keyboard.down() and keyboard.up(). Supports modifier keys like Control, Shift, Alt, Meta.
Upstream docs
key
string
required
Key to press (e.g., “Enter”, “Control+A”)
options
PlaywrightPressOptions
await locator.press('...');

pressSequentially

Types text character by character with keydown, keypress, and keyup events.
Use this for special keyboard handling. In most cases, fill() is preferred. The delay option can simulate realistic typing speed.
Upstream docs
text
string
required
Characters to type
options
PlaywrightPressSequentiallyOptions
await locator.pressSequentially('...');

type

Types text into the element (DEPRECATED - use fill() or pressSequentially()).
This method is deprecated. Use fill() for most cases, or pressSequentially() when special keyboard handling is required.
Upstream docs
text
string
required
options
{ delay?: number; noWaitAfter?: boolean; timeout?: number }
await locator.type('...');

hover

Hovers over the element.
Waits for actionability checks, scrolls element into view, and moves mouse to the center of the element.
Upstream docs
options
PlaywrightHoverOptions
await locator.hover();

tap

Performs a tap gesture on the element.
Requires hasTouch option to be enabled in browser context. Waits for actionability checks before performing the tap.
Upstream docs
options
PlaywrightTapOptions
await locator.tap();

focus

Focuses the element. Upstream docs
options
PlaywrightFocusOptions
await locator.focus();

blur

Removes focus from the element. Upstream docs
options
PlaywrightBlurOptions
await locator.blur();

check

Checks a checkbox or radio button.
If already checked, this method does nothing.
Upstream docs
options
PlaywrightCheckOptions
await locator.check();

uncheck

Unchecks a checkbox.
If already unchecked, this method does nothing.
Upstream docs
options
PlaywrightUncheckOptions
await locator.uncheck();

setChecked

Sets the checked state of a checkbox or radio button. Upstream docs
checked
boolean
required
Whether to check or uncheck
options
PlaywrightSetCheckedOptions
await locator.setChecked(true);

selectOption

Selects option(s) in a <select> element.
Waits for actionability checks, waits until all options are present, and triggers change and input events. Returns array of selected option values.
Upstream docs
values
string | string[] | PlaywrightSelectOptionValue | PlaywrightSelectOptionValue[]
required
Options to select by value, label, or index
options
PlaywrightSelectOptionOptions
result
string[]
Return value
await locator.selectOption(/* string | string[] | PlaywrightSelectOptionValue | PlaywrightSelectOptionValue[] */);

setInputFiles

Sets files for a file input element.
Pass empty array to clear selected files. Supports paths, objects with name/mimeType/buffer, or directories.
Upstream docs
files
string | string[] | PlaywrightFilePayload | PlaywrightFilePayload[]
required
File paths or file objects to upload
options
PlaywrightSetInputFilesOptions
await locator.setInputFiles(/* string | string[] | PlaywrightFilePayload | PlaywrightFilePayload[] */);

dragTo

Drags this element to the target element.
Performs mousedown on source, moves to target, and releases with mouseup. Supports sourcePosition and targetPosition options for precise control.
Upstream docs
target
RemotePlaywrightLocator
required
Target locator to drag to
options
PlaywrightDragToOptions
await locator.dragTo(/* RemotePlaywrightLocator */);

scrollIntoViewIfNeeded

Scrolls the element into view if not already visible.
Uses IntersectionObserver to determine if element is already visible.
Upstream docs
options
PlaywrightScrollIntoViewIfNeededOptions
await locator.scrollIntoViewIfNeeded();

dispatchEvent

Programmatically dispatches a DOM event on the element.
The event is created as composed, cancelable, and bubbles by default. Works regardless of element visibility state.
Upstream docs
type
string
required
DOM event type (e.g., “click”, “dragstart”)
eventInit
Record<string, unknown>
Event initialization properties
options
PlaywrightDispatchEventOptions
await locator.dispatchEvent('...');