Inheritance
Extends:ChannelOwner
Implements: EventEmitter
Events
load: Emitted when the load event is fireddomcontentloaded: Emitted when DOMContentLoaded event is firedclose: Emitted when page is closedcrash: Emitted when page crashesconsole: Emitted when console message is loggeddialog: Emitted when a dialog appearsdownload: Emitted when download startsfilechooser: Emitted when file chooser opensframeattached: Emitted when frame is attachedframedetached: Emitted when frame is detachedframenavigated: Emitted when frame navigatespageerror: Emitted when uncaught exception occurspopup: Emitted when popup is openedrequest: Emitted when request is maderesponse: Emitted when response is receivedrequestfailed: Emitted when request failsrequestfinished: Emitted when request finisheswebsocket: Emitted when WebSocket is createdworker: Emitted when worker is created
Properties
keyboard
Keyboard
Keyboard input instance.
mouse
Mouse
Mouse input instance.
touchscreen
Touchscreen
Touchscreen input instance.
request
APIRequestContext
API request context.
clock
Clock
Clock instance for time control.
coverage
Coverage
Coverage instance (Chromium only).
Navigation Methods
goto
Navigates to a URL.string
required
URL to navigate to
GotoOptions
Navigation options
timeout(number): Maximum time in millisecondswaitUntil(‘load’ | ‘domcontentloaded’ | ‘networkidle’ | ‘commit’): When to consider navigation succeededreferer(string): Referer header value
Promise<Response | null> - Main resource response
reload
Reloads the page.ReloadOptions
Reload options (same as goto)
Promise<Response | null> - Main resource response
goBack
Navigates to the previous page in history.NavigationOptions
Navigation options
Promise<Response | null> - Main resource response
goForward
Navigates to the next page in history.NavigationOptions
Navigation options
Promise<Response | null> - Main resource response
waitForNavigation
Waits for navigation to finish.WaitForNavigationOptions
Wait options
url(string | RegExp): URL pattern to wait forwaitUntil(string): When to consider navigation succeededtimeout(number): Maximum wait time
Promise<Response | null> - Response
waitForLoadState
Waits for load state to be reached.string
Load state to wait for (default: ‘load’)
TimeoutOptions
Timeout options
Promise<void>
waitForURL
Waits for page to navigate to matching URL.string | RegExp
required
URL pattern to wait for
WaitForURLOptions
Wait options
Promise<void>
Selector Methods
$
Finds an element matching the selector.string
required
Selector to query
object
strict(boolean): Throw if multiple elements match
Promise<ElementHandle | null> - Element handle or null
$$
Finds all elements matching the selector.string
required
Selector to query
Promise<ElementHandle[]> - Array of element handles
locator
Creates a locator.string
required
Selector to locate
LocatorOptions
Locator options
hasText(string | RegExp): Matches elements containing texthasNotText(string | RegExp): Matches elements not containing texthas(Locator): Matches elements containing another locatorhasNot(Locator): Matches elements not containing another locator
Locator - Locator instance
getByRole
Creates a locator by ARIA role.string
required
ARIA role
ByRoleOptions
Role options
Locator - Locator instance
getByText
Creates a locator by text content.string | RegExp
required
Text to match
object
exact(boolean): Exact match
Locator - Locator instance
getByLabel
Creates a locator by label text.string | RegExp
required
Label text to match
object
exact(boolean): Exact match
Locator - Locator instance
getByPlaceholder
Creates a locator by placeholder text.string | RegExp
required
Placeholder text to match
object
exact(boolean): Exact match
Locator - Locator instance
getByAltText
Creates a locator by alt text.string | RegExp
required
Alt text to match
object
exact(boolean): Exact match
Locator - Locator instance
getByTitle
Creates a locator by title attribute.string | RegExp
required
Title to match
object
exact(boolean): Exact match
Locator - Locator instance
getByTestId
Creates a locator by test ID.string | RegExp
required
Test ID to match
Locator - Locator instance
Action Methods
click
Clicks an element.string
required
Selector to click
ClickOptions
Click options
button(‘left’ | ‘right’ | ‘middle’): Mouse buttonclickCount(number): Number of clicksdelay(number): Delay between mousedown and mouseupposition(object): Click positionmodifiers(string[]): Modifier keysforce(boolean): Force click even if element is not actionablenoWaitAfter(boolean): Don’t wait for navigationtimeout(number): Maximum time in milliseconds
Promise<void>
dblclick
Double clicks an element.fill
Fills an input field.string
required
Selector to fill
string
required
Value to fill
FillOptions
Fill options
Promise<void>
type
Types text into an element.string
required
Selector to type into
string
required
Text to type
TypeOptions
Type options
delay(number): Delay between key presses in millisecondstimeout(number): Maximum time
Promise<void>
press
Presses a key.string
required
Selector to focus
string
required
Key to press (e.g., ‘Enter’, ‘ArrowDown’)
PressOptions
Press options
Promise<void>
check
Checks a checkbox.uncheck
Unchecks a checkbox.selectOption
Selects options in a<select> element.
string
required
Selector to select from
string | string[] | SelectOption | SelectOption[]
required
Values to select
SelectOptionOptions
Select options
Promise<string[]> - Array of selected values
hover
Hovers over an element.tap
Taps an element (mobile).dragAndDrop
Drags and drops an element.string
required
Source element selector
string
required
Target element selector
DragAndDropOptions
Drag options
Promise<void>
Content Methods
content
Returns page HTML content.Promise<string> - Full HTML content
setContent
Sets page HTML content.string
required
HTML content to set
SetContentOptions
Set content options
Promise<void>
title
Returns page title.Promise<string> - Page title
url
Returns page URL.string - Current URL
textContent
Returns element’s text content.innerText
Returns element’s inner text.innerHTML
Returns element’s inner HTML.getAttribute
Returns element’s attribute value.State Methods
isVisible
Checks if element is visible.isHidden
Checks if element is hidden.isEnabled
Checks if element is enabled.isDisabled
Checks if element is disabled.isChecked
Checks if checkbox is checked.isEditable
Checks if element is editable.Evaluation Methods
evaluate
Evaluates JavaScript in page context.Function | string
required
Function to evaluate
any
Argument to pass to function
Promise<R> - Evaluation result
evaluateHandle
Evaluates and returns a JSHandle.$eval
Evaluates function on an element.$$eval
Evaluates function on multiple elements.Frame Methods
mainFrame
Returns the main frame.Frame - Main frame
frames
Returns all frames.Frame[] - Array of frames
frame
Finds a frame by name or URL.string | object
required
Frame name or URL pattern
Frame | null - Matching frame or null
frameLocator
Creates a frame locator.string
required
Frame selector
FrameLocator - Frame locator instance
Utility Methods
screenshot
Takes a screenshot.ScreenshotOptions
Screenshot options
path(string): File path to save totype(‘png’ | ‘jpeg’): Image typequality(number): JPEG quality (0-100)fullPage(boolean): Capture full pageclip(object): Clip areaomitBackground(boolean): Transparent backgroundtimeout(number): Maximum timemask(Locator[]): Elements to mask
Promise<Buffer> - Screenshot buffer
PDFOptions
PDF options
path(string): File path to save toformat(string): Paper format (e.g., ‘A4’)width(string | number): Paper widthheight(string | number): Paper heightmargin(object): Page marginsprintBackground(boolean): Print background graphicslandscape(boolean): Landscape orientation
Promise<Buffer> - PDF buffer
close
Closes the page.object
runBeforeUnload(boolean): Run beforeunload handlersreason(string): Close reason
Promise<void>
isClosed
Checks if page is closed.boolean - True if closed
context
Returns the browser context.BrowserContext - Parent context
opener
Returns the opener page.Promise<Page | null> - Opener page or null
bringToFront
Brings page to front.Promise<void>
setViewportSize
Sets viewport size.object
required
Viewport dimensions
width(number): Width in pixelsheight(number): Height in pixels
Promise<void>
viewportSize
Returns viewport size.object | null - Viewport size or null
setDefaultTimeout
Sets default timeout.number
required
Timeout in milliseconds
setDefaultNavigationTimeout
Sets default navigation timeout.number
required
Timeout in milliseconds
workers
Returns all workers.Worker[] - Array of workers
Usage Examples
Basic Page Automation
Using Locators
Form Interactions
Related Classes
- BrowserContext - Parent context
- Frame - Page frames
- Locator - Element locators
- ElementHandle - Element handles
