Skip to main content
Frame represents an iframe on a page. Every page has a main frame and can have multiple child frames.

Inheritance

Extends: ChannelOwner

Methods

page

Returns the parent page.
Returns: Page - Parent page

name

Returns frame name.
Returns: string - Frame name attribute

url

Returns frame URL.
Returns: string - Frame URL

parentFrame

Returns parent frame.
Returns: Frame | null - Parent frame or null for main frame

childFrames

Returns child frames.
Returns: Frame[] - Array of child frames

isDetached

Checks if frame is detached.
Returns: boolean - True if detached

frameElement

Returns the frame element handle.
Returns: Promise<ElementHandle> - Frame element (iframe)

goto

Navigates to a URL.
string
required
URL to navigate to
GotoOptions
Navigation options
  • timeout (number): Maximum time in milliseconds
  • waitUntil (‘load’ | ‘domcontentloaded’ | ‘networkidle’ | ‘commit’): When to consider navigation succeeded
  • referer (string): Referer header
Returns: Promise<Response | null> - Response

waitForNavigation

Waits for navigation.
WaitForNavigationOptions
Wait options
  • url (string | RegExp): URL pattern to wait for
  • waitUntil (string): Wait condition
  • timeout (number): Maximum time
Returns: Promise<Response | null> - Response

waitForLoadState

Waits for load state.
string
Load state to wait for (default: ‘load’)
TimeoutOptions
Timeout options
Returns: Promise<void>

waitForURL

Waits for URL to match pattern.
string | RegExp
required
URL pattern to wait for
WaitForURLOptions
Wait options
Returns: Promise<void>

Selector Methods

$

Finds an element.
string
required
Selector to query
object
  • strict (boolean): Throw if multiple elements match
Returns: Promise<ElementHandle | null> - Element handle or null

$$

Finds all elements.
string
required
Selector to query
Returns: Promise<ElementHandle[]> - Array of element handles

waitForSelector

Waits for element to appear.
string
required
Selector to wait for
WaitForSelectorOptions
Wait options
  • state (‘attached’ | ‘visible’ | ‘hidden’ | ‘detached’): Element state to wait for
  • timeout (number): Maximum time
  • strict (boolean): Throw if multiple elements match
Returns: Promise<ElementHandle | null> - Element handle or null

locator

Creates a locator.
string
required
Selector to locate
LocatorOptions
Locator options
Returns: Locator - Locator instance

getByRole

Creates a locator by ARIA role.

getByText

Creates a locator by text.

getByLabel

Creates a locator by label.

getByPlaceholder

Creates a locator by placeholder.

getByAltText

Creates a locator by alt text.

getByTitle

Creates a locator by title.

getByTestId

Creates a locator by test ID.

frameLocator

Creates a frame locator.
string
required
Frame selector
Returns: FrameLocator - Frame locator instance

Action Methods

click

Clicks an element.

dblclick

Double clicks an element.

fill

Fills an input.

type

Types text.

press

Presses a key.

check

Checks a checkbox.

uncheck

Unchecks a checkbox.

setChecked

Sets checkbox state.

selectOption

Selects options.

hover

Hovers over element.

tap

Taps an element.

dragAndDrop

Drags and drops.

focus

Focuses an element.

setInputFiles

Sets input files.

dispatchEvent

Dispatches a DOM event.

Content Methods

content

Returns HTML content.
Returns: Promise<string> - Full HTML content

setContent

Sets HTML content.
string
required
HTML content to set
SetContentOptions
Set content options
Returns: Promise<void>

title

Returns page title.
Returns: Promise<string> - Page title

textContent

Returns element’s text content.

innerText

Returns element’s inner text.

innerHTML

Returns element’s inner HTML.

getAttribute

Returns attribute value.

inputValue

Returns input value.

State Methods

isVisible

Checks if visible.

isHidden

Checks if hidden.

isEnabled

Checks if enabled.

isDisabled

Checks if disabled.

isChecked

Checks if checked.

isEditable

Checks if editable.

Evaluation Methods

evaluate

Evaluates JavaScript.
Function | string
required
Function to evaluate
any
Argument to pass
Returns: Promise<R> - Evaluation result

evaluateHandle

Evaluates and returns JSHandle.

$eval

Evaluates on an element.

$$eval

Evaluates on multiple elements.

Script Methods

addScriptTag

Adds a script tag.
object
required
Script options
  • url (string): Script URL
  • path (string): Path to script file
  • content (string): Script content
  • type (string): Script type
Returns: Promise<ElementHandle> - Script element handle

addStyleTag

Adds a style tag.
object
required
Style options
  • url (string): Stylesheet URL
  • path (string): Path to stylesheet file
  • content (string): CSS content
Returns: Promise<ElementHandle> - Style element handle

Wait Methods

waitForTimeout

Waits for timeout.
number
required
Timeout in milliseconds
Returns: Promise<void>

waitForFunction

Waits for function to return truthy value.
Function | string
required
Function to evaluate
any
Argument to pass
WaitForFunctionOptions
Wait options
  • timeout (number): Maximum time
  • polling (number | ‘raf’): Polling interval
Returns: Promise<JSHandle<R>> - JS handle

Usage Examples

Working with Frames

Interacting with Frame Content

Frame Locators