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 input instance.
mouse
Mouse input instance.
touchscreen
Touchscreen input instance.
request
API request context.
clock
Clock instance for time control.
coverage
Coverage instance (Chromium only).
Navigation Methods
goto
Navigates to a URL.URL to navigate to
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.Reload options (same as goto)
Promise<Response | null> - Main resource response
goBack
Navigates to the previous page in history.Navigation options
Promise<Response | null> - Main resource response
goForward
Navigates to the next page in history.Navigation options
Promise<Response | null> - Main resource response
waitForNavigation
Waits for navigation to finish.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.Load state to wait for (default: ‘load’)
Timeout options
Promise<void>
waitForURL
Waits for page to navigate to matching URL.URL pattern to wait for
Wait options
Promise<void>
Selector Methods
$
Finds an element matching the selector.Selector to query
strict(boolean): Throw if multiple elements match
Promise<ElementHandle | null> - Element handle or null
$$
Finds all elements matching the selector.Selector to query
Promise<ElementHandle[]> - Array of element handles
locator
Creates a locator.Selector to locate
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.ARIA role
Role options
Locator - Locator instance
getByText
Creates a locator by text content.Text to match
exact(boolean): Exact match
Locator - Locator instance
getByLabel
Creates a locator by label text.Label text to match
exact(boolean): Exact match
Locator - Locator instance
getByPlaceholder
Creates a locator by placeholder text.Placeholder text to match
exact(boolean): Exact match
Locator - Locator instance
getByAltText
Creates a locator by alt text.Alt text to match
exact(boolean): Exact match
Locator - Locator instance
getByTitle
Creates a locator by title attribute.Title to match
exact(boolean): Exact match
Locator - Locator instance
getByTestId
Creates a locator by test ID.Test ID to match
Locator - Locator instance
Action Methods
click
Clicks an element.Selector to click
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.Selector to fill
Value to fill
Fill options
Promise<void>
type
Types text into an element.Selector to type into
Text to type
Type options
delay(number): Delay between key presses in millisecondstimeout(number): Maximum time
Promise<void>
press
Presses a key.Selector to focus
Key to press (e.g., ‘Enter’, ‘ArrowDown’)
Press options
Promise<void>
check
Checks a checkbox.uncheck
Unchecks a checkbox.selectOption
Selects options in a<select> element.
Selector to select from
Values to select
Select options
Promise<string[]> - Array of selected values
hover
Hovers over an element.tap
Taps an element (mobile).dragAndDrop
Drags and drops an element.Source element selector
Target element selector
Drag options
Promise<void>
Content Methods
content
Returns page HTML content.Promise<string> - Full HTML content
setContent
Sets page HTML content.HTML content to set
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 to evaluate
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.Frame name or URL pattern
Frame | null - Matching frame or null
frameLocator
Creates a frame locator.Frame selector
FrameLocator - Frame locator instance
Utility Methods
screenshot
Takes a screenshot.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
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.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.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.Timeout in milliseconds
setDefaultNavigationTimeout
Sets default navigation timeout.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
