Skip to main content
Element Handle actions methods for the Playwright driver.

click

Click the element.
This method clicks the element by performing actionability checks, scrolling into view, and simulating a mouse click. Discouraged in favor of locator.click().
Upstream docs
options
PlaywrightClickOptions
await element.click();

dblclick

Double-click the element.
Discouraged in favor of locator.dblclick().
Upstream docs
options
PlaywrightClickOptions
await element.dblclick();

fill

Fill an input, textarea, or contenteditable element with the specified value.
This method waits for actionability checks, focuses the element, fills it, and triggers an input event. Pass empty string to clear. Discouraged in favor of locator.fill().
Upstream docs
value
string
required
options
PlaywrightFillOptions
await element.fill('...');

type

Focus the element and type text into it character by character.
Deprecated: In most cases use locator.fill() instead. Only use this for special keyboard handling. For special keys use press().
Upstream docs
text
string
required
options
PlaywrightTypeOptions
await element.type('...');

press

Focus the element and press a key or key combination.
Key can be a single character or a special key like “Enter”, “Control+a”, “Shift+ArrowDown”. Discouraged in favor of locator.press().
Upstream docs
key
string
required
options
PlaywrightPressOptions
await element.press('...');

hover

Hover over the element.
This method hovers over the element by performing actionability checks, scrolling into view, and simulating mouse hover. Discouraged in favor of locator.hover().
Upstream docs
options
PlaywrightHoverOptions
await element.hover();

focus

Focus the element.
Discouraged in favor of locator.focus().
Upstream docs
await element.focus();

tap

Tap the element (for touch devices).
This method taps the element by performing actionability checks, scrolling into view, centering, and dispatching touchstart/touchend events. Discouraged in favor of locator.tap().
Upstream docs
options
PlaywrightTapOptions
await element.tap();

check

Check a checkbox or radio element.
If the element is already checked, this method returns immediately. Discouraged in favor of locator.check().
Upstream docs
options
PlaywrightCheckOptions
await element.check();

uncheck

Uncheck a checkbox element.
If the element is already unchecked, this method returns immediately. Discouraged in favor of locator.uncheck().
Upstream docs
options
PlaywrightCheckOptions
await element.uncheck();

setChecked

Check or uncheck a checkbox or radio element.
Discouraged in favor of locator.setChecked().
Upstream docs
checked
boolean
required
options
PlaywrightCheckOptions
await element.setChecked(true);

selectOption

Select one or more options in a <select> element.
Discouraged in favor of locator.selectOption().
Upstream docs
values
string | string[] | PlaywrightSelectOption | PlaywrightSelectOption[]
required
Options to select. Can be value, label, or option object.
options
PlaywrightSelectOptionOptions
result
string[]
Return value
await element.selectOption(/* string | string[] | PlaywrightSelectOption | PlaywrightSelectOption[] */);

setInputFiles

Set the files for a file input element.
Sets the value of the file input to these file paths or files. If some paths are relative, they are resolved relative to the current working directory. Clears selected files if empty array is passed. Discouraged in favor of locator.setInputFiles().
Upstream docs
files
string | string[] | PlaywrightFilePayload | PlaywrightFilePayload[]
required
File paths or file payloads to upload.
options
PlaywrightSetInputFilesOptions
await element.setInputFiles(/* string | string[] | PlaywrightFilePayload | PlaywrightFilePayload[] */);

scrollIntoViewIfNeeded

Scroll the element into view if not already visible.
If the element is detached from DOM, throws an error. Discouraged in favor of locator.scrollIntoViewIfNeeded().
Upstream docs
options
PlaywrightTimeoutOptions
await element.scrollIntoViewIfNeeded();

dispatchEvent

Dispatch a DOM event on the element.
The event is composed, cancelable and bubbles by default. Regardless of visibility, this will dispatch the event. Discouraged in favor of locator.dispatchEvent().
Upstream docs
type
string
required
DOM event type, e.g., “click”.
eventInit
PlaywrightEventInit
Event-specific initialization properties.
await element.dispatchEvent('...');