Playwright Frame

View as Markdown

All Frame methods available when using the Playwright driver.

Access via frame after launching a Playwright runtime.

Every method below is a remote call. The SDK translates it into a structured step sent to a single endpoint:

POST /v1/workspaces/{workspaceId}/execute
1{
2 "runtime": "my-browser",
3 "steps": [
4 {
5 "call": "frame.goto",
6 "args": ["https://example.com"]
7 }
8 ]
9}

The call field maps directly to the method name. args is a JSON array of the method’s arguments. You can batch multiple steps in one request.

goto(url, options?)

Returns the main resource response.

Navigates the frame to the given URL. In case of multiple redirects, the navigation will resolve with the first non-redirect response. The method will throw an error if navigation fails. The method will not throw an error when any valid HTTP status code is returned by the remote server.

1await frame.goto('...');
ParameterTypeRequiredDescription
urlstringYes
optionsPlaywrightGotoOptionsNo

Returns SerializedHandle \| null

Upstream docs


waitForURL(url, options?)

Waits for the frame to navigate to the given URL.

This method can be used after an action that causes navigation. A glob pattern, regex pattern or predicate receiving URL to match while waiting for the navigation.

1await frame.waitForURL(/* url */);
ParameterTypeRequiredDescription
urlstring | RegExp | ((url: URL) => boolean)Yes
optionsPlaywrightWaitForURLOptionsNo

Upstream docs


waitForLoadState(state?, options?)

Waits for the required load state to be reached.

This method returns when the page reaches a required load state, ‘load’ by default. The navigation must have been committed when this method is called.

1await frame.waitForLoadState();
ParameterTypeRequiredDescription
state"load" | "domcontentloaded" | "networkidle"NoState to wait for, defaults to load.
options{ timeout?: number }No

Upstream docs


Page Info

url()

Returns frame’s URL.

1await frame.url();

Returns string

Upstream docs


title()

Returns the page title.

1await frame.title();

Returns string

Upstream docs


content()

Gets the full HTML contents of the frame, including the doctype.

1await frame.content();

Returns string

Upstream docs


setContent(html, options?)

Sets the content of the frame.

This method takes the HTML to set as the frame’s content. The default waitUntil is ‘load’.

1await frame.setContent('...');
ParameterTypeRequiredDescription
htmlstringYes
options{ timeout?: number; waitUntil?: "load" | "domcontentloaded" | "networkidle" | "commit" }No

Upstream docs


Actions

click(selector, options?)

Clicks an element matching selector.

This method waits for actionability checks, scrolls element into view, and then clicks the center of the element. Discouraged: use locator-based locator.click() instead.

1await frame.click('...');
ParameterTypeRequiredDescription
selectorstringYes
optionsPlaywrightClickOptionsNo

Upstream docs


dblclick(selector, options?)

Double-clicks an element matching selector.

This method waits for actionability checks, scrolls element into view, and then double-clicks the center of the element. Discouraged: use locator-based locator.dblclick() instead.

1await frame.dblclick('...');
ParameterTypeRequiredDescription
selectorstringYes
optionsPlaywrightClickOptionsNo

Upstream docs


fill(selector, value, options?)

Fills a form field with text.

This method waits for an element matching selector, waits for actionability checks, focuses the element, fills it and triggers an input event. Discouraged: use locator-based locator.fill() instead.

1await frame.fill('...', '...');
ParameterTypeRequiredDescription
selectorstringYes
valuestringYes
optionsPlaywrightFillOptionsNo

Upstream docs


type(selector, text, options?)

Types into an element matching selector.

Sends a keydown, keypress/input, and keyup event for each character in the text. Discouraged: In most cases, you should use locator.fill() instead.

1await frame.type('...', '...');
ParameterTypeRequiredDescription
selectorstringYes
textstringYes
optionsPlaywrightTypeOptionsNo

Upstream docs


press(selector, key, options?)

Presses a key.

Focuses the element matching selector, and then uses keyboard.press. Discouraged: use locator-based locator.press() instead.

1await frame.press('...', '...');
ParameterTypeRequiredDescription
selectorstringYes
keystringYes
optionsPlaywrightPressOptionsNo

Upstream docs


hover(selector, options?)

Hovers over an element matching selector.

This method waits for actionability checks, scrolls element into view, and then hovers over the center of the element. Discouraged: use locator-based locator.hover() instead.

1await frame.hover('...');
ParameterTypeRequiredDescription
selectorstringYes
optionsPlaywrightHoverOptionsNo

Upstream docs


focus(selector, options?)

Fetches the element matching selector and focuses it.

If there is no element matching selector, the method waits until a matching element appears in the DOM. Discouraged: use locator-based locator.focus() instead.

1await frame.focus('...');
ParameterTypeRequiredDescription
selectorstringYes
optionsPlaywrightFocusOptionsNo

Upstream docs


tap(selector, options?)

Taps an element matching selector.

This method waits for actionability checks, scrolls element into view, and then taps the center of the element. Discouraged: use locator-based locator.tap() instead.

1await frame.tap('...');
ParameterTypeRequiredDescription
selectorstringYes
options{ force?: boolean; modifiers?: ("Alt" | "Control" | "Meta" | "Shift")[]; noWaitAfter?: boolean; position?: { x: number; y: number }; strict?: boolean; timeout?: number; trial?: boolean }No

Upstream docs


check(selector, options?)

Checks a checkbox or radio element.

This method checks an element matching selector by performing the following steps: scrolls element into view, and then uses click to check the element. Discouraged: use locator-based locator.check() instead.

1await frame.check('...');
ParameterTypeRequiredDescription
selectorstringYes
optionsPlaywrightCheckOptionsNo

Upstream docs


uncheck(selector, options?)

Unchecks a checkbox element.

This method unchecks an element matching selector by scrolling element into view and using click to uncheck the element. Discouraged: use locator-based locator.uncheck() instead.

1await frame.uncheck('...');
ParameterTypeRequiredDescription
selectorstringYes
optionsPlaywrightCheckOptionsNo

Upstream docs


setChecked(selector, checked, options?)

Checks or unchecks a checkbox or radio element.

This method checks or unchecks an element matching selector. Discouraged: use locator-based locator.setChecked() instead.

1await frame.setChecked('...', true);
ParameterTypeRequiredDescription
selectorstringYes
checkedbooleanYes
optionsPlaywrightCheckOptionsNo

Upstream docs


selectOption(selector, values, options?)

Selects option(s) in the select element.

Returns array of selected option values. Shortcuts such as “blue” match both value and label. Objects such as { label: “blue” } match by label only. Discouraged: use locator-based locator.selectOption() instead.

1await frame.selectOption('...', /* values */);
ParameterTypeRequiredDescription
selectorstringYes
valuesstring | string[] | { value?: string; label?: string; index?: number } | { value?: string; label?: string; index?: number }[] | nullYes
optionsPlaywrightSelectOptionOptionsNo

Returns string[]

Upstream docs


setInputFiles(selector, files, options?)

Sets the file input element to the given files.

Empty array clears the selected files. Discouraged: use locator-based locator.setInputFiles() instead.

1await frame.setInputFiles('...', /* files */);
ParameterTypeRequiredDescription
selectorstringYes
filesstring | string[] | { name: string; mimeType: string; buffer: Buffer } | { name: string; mimeType: string; buffer: Buffer }[]Yes
options{ noWaitAfter?: boolean; strict?: boolean; timeout?: number }No

Upstream docs


dragAndDrop(source, target, options?)

Drags source element to target element.

This method drags the source element to the target element. It will first move to the source element, perform a mousedown, then move to the target element and perform a mouseup.

1await frame.dragAndDrop('...', '...');
ParameterTypeRequiredDescription
sourcestringYes
targetstringYes
options{ force?: boolean; noWaitAfter?: boolean; sourcePosition?: { x: number; y: number }; strict?: boolean; targetPosition?: { x: number; y: number }; timeout?: number; trial?: boolean }No

Upstream docs


dispatchEvent(selector, type, eventInit?, options?)

Dispatches an event on the element.

This method dispatches a DOM event on the element matching selector. Events are composed, cancelable, and bubble by default. Discouraged: use locator-based locator.dispatchEvent() instead.

1await frame.dispatchEvent('...', '...');
ParameterTypeRequiredDescription
selectorstringYes
typestringYes
eventInitunknownNo
options{ strict?: boolean; timeout?: number }No

Upstream docs


Queries

page()

Returns the page containing this frame.

Returns the cached page reference passed at construction time.

1frame.page();

Returns RemotePlaywrightPage

Upstream docs


locator(selector, options?)

The method returns a Locator for the given selector.

The locator is a building block for accessing and interacting with elements on the page. Locators are strict by default - they will throw if more than one element matches the selector.

1frame.locator('...');
ParameterTypeRequiredDescription
selectorstringYes
options{ has?: RemotePlaywrightLocator; hasNot?: RemotePlaywrightLocator; hasText?: string | RegExp; hasNotText?: string | RegExp }No

Returns RemotePlaywrightLocator

Upstream docs


frameLocator(selector)

Returns a FrameLocator for the given selector.

Use this when the <iframe> is lazy loaded. Use has and hasText options to locate elements inside a frame based on their content.

1frame.frameLocator('...');
ParameterTypeRequiredDescription
selectorstringYes

Returns RemotePlaywrightFrameLocator

Upstream docs


getByRole(role, options?)

Allows locating elements by their ARIA role, ARIA attributes and accessible name.

1frame.getByRole(/* role */);
ParameterTypeRequiredDescription
role"alert" | "alertdialog" | "application" | "article" | "banner" | "blockquote" | "button" | "caption" | "cell" | "checkbox" | "code" | "columnheader" | "combobox" | "complementary" | "contentinfo" | "definition" | "deletion" | "dialog" | "directory" | "document" | "emphasis" | "feed" | "figure" | "form" | "generic" | "grid" | "gridcell" | "group" | "heading" | "img" | "insertion" | "link" | "list" | "listbox" | "listitem" | "log" | "main" | "marquee" | "math" | "meter" | "menu" | "menubar" | "menuitem" | "menuitemcheckbox" | "menuitemradio" | "navigation" | "none" | "note" | "option" | "paragraph" | "presentation" | "progressbar" | "radio" | "radiogroup" | "region" | "row" | "rowgroup" | "rowheader" | "scrollbar" | "search" | "searchbox" | "separator" | "slider" | "spinbutton" | "status" | "strong" | "subscript" | "superscript" | "switch" | "tab" | "table" | "tablist" | "tabpanel" | "term" | "textbox" | "time" | "timer" | "toolbar" | "tooltip" | "tree" | "treegrid" | "treeitem"Yes
optionsPlaywrightGetByRoleOptionsNo

Returns RemotePlaywrightLocator

Upstream docs


getByText(text, options?)

Allows locating elements that contain given text.

Matching by text always normalizes whitespace, even with exact match. For example, it turns multiple spaces into one, turns line breaks into spaces and ignores leading and trailing whitespace.

1frame.getByText(/* text */);
ParameterTypeRequiredDescription
textstring | RegExpYes
optionsPlaywrightGetByTextOptionsNo

Returns RemotePlaywrightLocator

Upstream docs


getByLabel(text, options?)

Allows locating input elements by the text of the associated <label> or aria-labelledby element, or by the aria-label attribute.

1frame.getByLabel(/* text */);
ParameterTypeRequiredDescription
textstring | RegExpYes
optionsPlaywrightGetByLabelOptionsNo

Returns RemotePlaywrightLocator

Upstream docs


getByPlaceholder(text, options?)

Allows locating input elements by the placeholder text.

1frame.getByPlaceholder(/* text */);
ParameterTypeRequiredDescription
textstring | RegExpYes
optionsPlaywrightGetByPlaceholderOptionsNo

Returns RemotePlaywrightLocator

Upstream docs


getByAltText(text, options?)

Allows locating elements by their alt text.

This method allows locating elements by their alt text. It works with <img> and <area> elements.

1frame.getByAltText(/* text */);
ParameterTypeRequiredDescription
textstring | RegExpYes
optionsPlaywrightGetByAltTextOptionsNo

Returns RemotePlaywrightLocator

Upstream docs


getByTitle(text, options?)

Allows locating elements by their title attribute.

1frame.getByTitle(/* text */);
ParameterTypeRequiredDescription
textstring | RegExpYes
optionsPlaywrightGetByTitleOptionsNo

Returns RemotePlaywrightLocator

Upstream docs


getByTestId(testId)

Locate element by the test id.

By default, the data-testid attribute is used as a test id. Use selectors.setTestIdAttribute() to configure a different test id attribute if necessary.

1frame.getByTestId(/* testId */);
ParameterTypeRequiredDescription
testIdstring | RegExpYes

Returns RemotePlaywrightLocator

Upstream docs


$(selector)

Returns the ElementHandle pointing to the frame element.

This method queries the frame for the given selector. If no element matches the selector, returns null. Discouraged: use locator-based frame.locator() instead.

1await frame.$('...');
ParameterTypeRequiredDescription
selectorstringYes

Returns RemotePlaywrightElementHandle \| null

Upstream docs


$$(selector)

Returns the ElementHandles pointing to the frame elements.

This method queries the frame for all elements matching the given selector. Returns empty array if no elements match. Discouraged: use locator-based frame.locator() instead.

1await frame.$$('...');
ParameterTypeRequiredDescription
selectorstringYes

Returns RemotePlaywrightElementHandle[]

Upstream docs


Content

textContent(selector, options?)

Returns the element.textContent.

Discouraged: use locator-based locator.textContent() instead.

1await frame.textContent('...');
ParameterTypeRequiredDescription
selectorstringYes
optionsPlaywrightTextContentOptionsNo

Returns string \| null

Upstream docs


innerText(selector, options?)

Returns the element.innerText.

Discouraged: use locator-based locator.innerText() instead.

1await frame.innerText('...');
ParameterTypeRequiredDescription
selectorstringYes
optionsPlaywrightInnerTextOptionsNo

Returns string

Upstream docs


innerHTML(selector, options?)

Returns the element.innerHTML.

Discouraged: use locator-based locator.innerHTML() instead.

1await frame.innerHTML('...');
ParameterTypeRequiredDescription
selectorstringYes
optionsPlaywrightInnerHTMLOptionsNo

Returns string

Upstream docs


getAttribute(selector, name, options?)

Returns element attribute value.

Discouraged: use locator-based locator.getAttribute() instead.

1await frame.getAttribute('...', '...');
ParameterTypeRequiredDescription
selectorstringYes
namestringYes
optionsPlaywrightGetAttributeOptionsNo

Returns string \| null

Upstream docs


inputValue(selector, options?)

Returns input.value for the selected <input> or <textarea> or <select> element.

Throws for non-input elements. Discouraged: use locator-based locator.inputValue() instead.

1await frame.inputValue('...');
ParameterTypeRequiredDescription
selectorstringYes
optionsPlaywrightInputValueOptionsNo

Returns string

Upstream docs


State Checks

isDetached()

Returns true if the frame has been detached, or false otherwise.

1frame.isDetached();

Returns boolean

Upstream docs


isChecked(selector, options?)

Returns whether the element is checked.

Throws if the element is not a checkbox or radio input. Discouraged: use locator-based locator.isChecked() instead.

1await frame.isChecked('...');
ParameterTypeRequiredDescription
selectorstringYes
optionsPlaywrightIsOptionsNo

Returns boolean

Upstream docs


isDisabled(selector, options?)

Returns whether the element is disabled.

Discouraged: use locator-based locator.isDisabled() instead.

1await frame.isDisabled('...');
ParameterTypeRequiredDescription
selectorstringYes
optionsPlaywrightIsOptionsNo

Returns boolean

Upstream docs


isEditable(selector, options?)

Returns whether the element is editable.

Discouraged: use locator-based locator.isEditable() instead.

1await frame.isEditable('...');
ParameterTypeRequiredDescription
selectorstringYes
optionsPlaywrightIsOptionsNo

Returns boolean

Upstream docs


isEnabled(selector, options?)

Returns whether the element is enabled.

Discouraged: use locator-based locator.isEnabled() instead.

1await frame.isEnabled('...');
ParameterTypeRequiredDescription
selectorstringYes
optionsPlaywrightIsOptionsNo

Returns boolean

Upstream docs


isHidden(selector, options?)

Returns whether the element is hidden.

Opposite of isVisible(). Discouraged: use locator-based locator.isHidden() instead.

1await frame.isHidden('...');
ParameterTypeRequiredDescription
selectorstringYes
optionsPlaywrightIsOptionsNo

Returns boolean

Upstream docs


isVisible(selector, options?)

Returns whether the element is visible.

Element is considered visible if it has non-zero bounding box and is not visibility:hidden. Discouraged: use locator-based locator.isVisible() instead.

1await frame.isVisible('...');
ParameterTypeRequiredDescription
selectorstringYes
optionsPlaywrightIsOptionsNo

Returns boolean

Upstream docs


Waiting

waitForSelector(selector, options?)

Returns when element specified by selector satisfies state option.

Returns null if waiting for hidden or detached. Returns the ElementHandle matching the selector in visible/attached states. Discouraged: use locator-based locator.waitFor() instead.

1await frame.waitForSelector('...');
ParameterTypeRequiredDescription
selectorstringYes
optionsPlaywrightWaitForSelectorOptionsNo

Returns RemotePlaywrightElementHandle \| null

Upstream docs


waitForTimeout(timeout)

Waits for the given timeout in milliseconds.

Note: This should never be used in production. Tests that wait for time are inherently flaky. Use Locator actions and web assertions that wait automatically.

1await frame.waitForTimeout(0);
ParameterTypeRequiredDescription
timeoutnumberYes

Upstream docs


waitForFunction(pageFunction, arg?, options?)

Returns when the pageFunction returns a truthy value.

It resolves to a JSHandle of the truthy value. The function is called periodically. You can pass a polling interval.

1await frame.waitForFunction('...');
ParameterTypeRequiredDescription
pageFunctionstring | ((...args: unknown[]) =&gt; R | Promise&lt;R&gt;)Yes
argunknownNo
options{ timeout?: number; polling?: number | "raf" }No

Returns unknown

Upstream docs


Evaluation

evaluate(pageFunction, arg?)

Evaluates JavaScript in the frame context.

Returns the return value of pageFunction. If the function returns a Promise, evaluate will wait for that Promise to resolve and return its value.

1await frame.evaluate('...');
ParameterTypeRequiredDescription
pageFunctionstring | ((...args: unknown[]) =&gt; R | Promise&lt;R&gt;)Yes
argunknownNo

Returns R

Upstream docs


evaluateHandle(pageFunction, arg?)

Evaluates a function in the frame’s context and returns a handle to the result.

Returns a JSHandle for the in-page object. Unlike evaluate, this does not return the value of the function, but a handle pointing to the value.

1await frame.evaluateHandle('...');
ParameterTypeRequiredDescription
pageFunctionstring | ((...args: unknown[]) =&gt; R | Promise&lt;R&gt;)Yes
argunknownNo

Returns unknown

Upstream docs


$eval(selector, pageFunction, arg?)

Finds an element matching selector and passes it to pageFunction.

Returns the value of pageFunction. Throws if selector matches no elements. Discouraged: use locator-based locator.evaluate() instead.

1await frame.$eval('...', '...');
ParameterTypeRequiredDescription
selectorstringYes
pageFunctionstring | ((element: Element, ...args: unknown[]) =&gt; R | Promise&lt;R&gt;)Yes
argunknownNo

Returns R

Upstream docs


$$eval(selector, pageFunction, arg?)

Finds all elements matching selector and passes them to pageFunction.

Returns the value of pageFunction. Discouraged: use locator-based locator.evaluateAll() instead.

1await frame.$$eval('...', '...');
ParameterTypeRequiredDescription
selectorstringYes
pageFunctionstring | ((elements: Element[], ...args: unknown[]) =&gt; R | Promise&lt;R&gt;)Yes
argunknownNo

Returns R

Upstream docs


Other

frameElement()

Returns the frame element associated with this frame.

Returns the ElementHandle for the <iframe> or <frame> tag for this frame. Returns null for the main frame.

1await frame.frameElement();

Returns RemotePlaywrightElementHandle

Upstream docs


name()

Returns frame’s name attribute as specified in the tag.

If the name is empty, returns the id attribute instead. Returns empty string if both name and id are empty.

1await frame.name();

Returns string

Upstream docs


parentFrame()

Parent frame, if any. Detached frames and main frames return null.

1await frame.parentFrame();

Returns RemotePlaywrightFrame \| null

Upstream docs


childFrames()

Returns child frames of this frame.

1await frame.childFrames();

Returns RemotePlaywrightFrame[]

Upstream docs


addScriptTag(options?)

Adds a <script> tag into the page with the desired url or content.

Returns the added tag when the script’s onload fires or when the script content was injected into frame.

1await frame.addScriptTag();
ParameterTypeRequiredDescription
options{ content?: string; path?: string; type?: string; url?: string }No

Returns RemotePlaywrightElementHandle

Upstream docs


addStyleTag(options?)

Adds a <style> tag into the page with the desired url or content.

Returns the added tag when the stylesheet’s onload fires or when the CSS content was injected into frame.

1await frame.addStyleTag();
ParameterTypeRequiredDescription
options{ content?: string; path?: string; url?: string }No

Returns RemotePlaywrightElementHandle

Upstream docs