Playwright Frame
All Frame methods available when using the Playwright driver.
Access via frame after launching a Playwright runtime.
How these methods work over HTTP
Every method below is a remote call. The SDK translates it into a structured step sent to a single endpoint:
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.
Navigation
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.
Returns SerializedHandle \| null
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.
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.
Page Info
url()
Returns frame’s URL.
Returns string
title()
Returns the page title.
Returns string
content()
Gets the full HTML contents of the frame, including the doctype.
Returns string
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’.
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.
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.
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.
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.
press(selector, key, options?)
Presses a key.
Focuses the element matching selector, and then uses keyboard.press. Discouraged: use locator-based locator.press() instead.
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.
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.
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.
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.
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.
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.
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.
Returns string[]
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.
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.
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.
Queries
page()
Returns the page containing this frame.
Returns the cached page reference passed at construction time.
Returns RemotePlaywrightPage
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.
Returns RemotePlaywrightLocator
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.
Returns RemotePlaywrightFrameLocator
getByRole(role, options?)
Allows locating elements by their ARIA role, ARIA attributes and accessible name.
Returns RemotePlaywrightLocator
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.
Returns RemotePlaywrightLocator
getByLabel(text, options?)
Allows locating input elements by the text of the associated <label> or aria-labelledby element, or by the aria-label attribute.
Returns RemotePlaywrightLocator
getByPlaceholder(text, options?)
Allows locating input elements by the placeholder text.
Returns RemotePlaywrightLocator
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.
Returns RemotePlaywrightLocator
getByTitle(text, options?)
Allows locating elements by their title attribute.
Returns RemotePlaywrightLocator
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.
Returns RemotePlaywrightLocator
$(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.
Returns RemotePlaywrightElementHandle \| null
$$(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.
Returns RemotePlaywrightElementHandle[]
Content
textContent(selector, options?)
Returns the element.textContent.
Discouraged: use locator-based locator.textContent() instead.
Returns string \| null
innerText(selector, options?)
Returns the element.innerText.
Discouraged: use locator-based locator.innerText() instead.
Returns string
innerHTML(selector, options?)
Returns the element.innerHTML.
Discouraged: use locator-based locator.innerHTML() instead.
Returns string
getAttribute(selector, name, options?)
Returns element attribute value.
Discouraged: use locator-based locator.getAttribute() instead.
Returns string \| null
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.
Returns string
State Checks
isDetached()
Returns true if the frame has been detached, or false otherwise.
Returns boolean
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.
Returns boolean
isDisabled(selector, options?)
Returns whether the element is disabled.
Discouraged: use locator-based locator.isDisabled() instead.
Returns boolean
isEditable(selector, options?)
Returns whether the element is editable.
Discouraged: use locator-based locator.isEditable() instead.
Returns boolean
isEnabled(selector, options?)
Returns whether the element is enabled.
Discouraged: use locator-based locator.isEnabled() instead.
Returns boolean
isHidden(selector, options?)
Returns whether the element is hidden.
Opposite of isVisible(). Discouraged: use locator-based locator.isHidden() instead.
Returns boolean
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.
Returns boolean
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.
Returns RemotePlaywrightElementHandle \| null
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.
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.
Returns unknown
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.
Returns R
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.
Returns unknown
$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.
Returns R
$$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.
Returns R
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.
Returns RemotePlaywrightElementHandle
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.
Returns string
parentFrame()
Parent frame, if any. Detached frames and main frames return null.
Returns RemotePlaywrightFrame \| null
childFrames()
Returns child frames of this frame.
Returns RemotePlaywrightFrame[]
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.
Returns RemotePlaywrightElementHandle
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.
Returns RemotePlaywrightElementHandle

