Playwright Page
All Page methods available when using the Playwright driver.
Access via runtime.page 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?)
Navigate to a URL.
Returns PlaywrightResponse \| null
— The main resource response, or null if navigating to about:blank.
reload(options?)
Reload the page.
Returns PlaywrightResponse \| null
goBack(options?)
Navigate back in history.
Returns PlaywrightResponse \| null
goForward(options?)
Navigate forward in history.
Returns PlaywrightResponse \| null
waitForURL(url, options?)
Wait for the main frame to navigate to the given URL.
waitForLoadState(state?, options?)
Wait for the required load state to be reached.
State can be ‘load’, ‘domcontentloaded’, or ‘networkidle’.
waitForNavigation(options?)
Wait for the main frame navigation and return the main resource response.
Deprecated: This method is inherently racy. Use page.waitForURL() instead.
Returns PlaywrightResponse \| null
Page Info
title()
Get the page title.
Returns string
url()
Get the current URL.
Returns string
content()
Get the full HTML content of the page.
Returns string
setContent(html, options?)
Set the HTML content of the page.
setViewportSize(viewportSize)
Set the viewport size.
viewportSize()
Get the viewport size.
Returns PlaywrightViewportSize \| null
isClosed()
Check if the page is closed.
Returns boolean
Actions
click(selector, options?)
Click on an element matching the selector.
Deprecated: Use locator.click() instead.
dblclick(selector, options?)
Double-click on an element matching the selector.
Deprecated: Use locator.dblclick() instead.
fill(selector, value, options?)
Fill an input element with the given value.
Deprecated: Use locator.fill() instead.
type(selector, text, options?)
Type text into an element (sends keydown, keypress/input, keyup events for each character).
Deprecated: Use locator.pressSequentially() instead.
press(selector, key, options?)
Focus an element and press a key combination.
Deprecated: Use locator.press() instead.
hover(selector, options?)
Hover over an element.
Deprecated: Use locator.hover() instead.
focus(selector, options?)
Focus on an element.
Deprecated: Use locator.focus() instead.
tap(selector, options?)
Tap on an element (for touch devices).
Deprecated: Use locator.tap() instead.
check(selector, options?)
Check a checkbox or radio button.
Deprecated: Use locator.check() instead.
uncheck(selector, options?)
Uncheck a checkbox.
Deprecated: Use locator.uncheck() instead.
setChecked(selector, checked, options?)
Set the checked state of a checkbox.
Deprecated: Use locator.setChecked() instead.
selectOption(selector, values, options?)
Select one or more options in a <select> element.
Deprecated: Use locator.selectOption() instead.
Returns string[]
setInputFiles(selector, files, options?)
Set input files for a file input element.
Deprecated: Use locator.setInputFiles() instead.
dispatchEvent(selector, type, eventInit?, options?)
Dispatch a DOM event on an element.
Deprecated: Use locator.dispatchEvent() instead.
dragAndDrop(source, target, options?)
Drag an element to another element.
Queries
$(selector)
Query for a single element. Alias for page.querySelector().
Deprecated: Use locator() instead.
Returns RemotePlaywrightElementHandle \| null
$$(selector)
Query for all matching elements. Alias for page.querySelectorAll().
Deprecated: Use locator() instead.
Returns RemotePlaywrightElementHandle[]
querySelector(selector)
Query for a single element.
Deprecated: Use locator() instead.
Returns RemotePlaywrightElementHandle \| null
querySelectorAll(selector)
Query for all matching elements.
Deprecated: Use locator() instead.
Returns RemotePlaywrightElementHandle[]
locator(selector, options?)
Create a locator for the given selector.
Returns RemotePlaywrightLocator
getByRole(role, options?)
Locate elements by their ARIA role, ARIA attributes, and accessible name.
Returns RemotePlaywrightLocator
getByText(text, options?)
Locate elements containing the given text.
Returns RemotePlaywrightLocator
getByLabel(text, options?)
Locate form controls by the text of their associated labels.
Returns RemotePlaywrightLocator
getByPlaceholder(text, options?)
Locate input elements by their placeholder text.
Returns RemotePlaywrightLocator
getByAltText(text, options?)
Locate elements by their alt text.
Returns RemotePlaywrightLocator
getByTitle(text, options?)
Locate elements by their title attribute.
Returns RemotePlaywrightLocator
getByTestId(testId)
Locate elements by their data-testid attribute.
Returns RemotePlaywrightLocator
frameLocator(selector)
Create a frame locator for the given selector.
Returns RemotePlaywrightLocator
Content
getAttribute(selector, name, options?)
Get an attribute value from an element.
Deprecated: Use locator.getAttribute() instead.
Returns string \| null
textContent(selector, options?)
Get the text content of an element.
Deprecated: Use locator.textContent() instead.
Returns string \| null
innerText(selector, options?)
Get the inner text of an element.
Deprecated: Use locator.innerText() instead.
Returns string
innerHTML(selector, options?)
Get the inner HTML of an element.
Deprecated: Use locator.innerHTML() instead.
Returns string
inputValue(selector, options?)
Get the input value of an element.
Deprecated: Use locator.inputValue() instead.
Returns string
State Checks
isVisible(selector, options?)
Check if an element is visible.
Deprecated: Use locator.isVisible() instead.
Returns boolean
isHidden(selector, options?)
Check if an element is hidden.
Deprecated: Use locator.isHidden() instead.
Returns boolean
isEnabled(selector, options?)
Check if an element is enabled.
Deprecated: Use locator.isEnabled() instead.
Returns boolean
isDisabled(selector, options?)
Check if an element is disabled.
Deprecated: Use locator.isDisabled() instead.
Returns boolean
isEditable(selector, options?)
Check if an element is editable.
Deprecated: Use locator.isEditable() instead.
Returns boolean
isChecked(selector, options?)
Check if a checkbox is checked.
Deprecated: Use locator.isChecked() instead.
Returns boolean
Waiting
waitForSelector(selector, options?)
Wait for a selector to appear in the DOM.
Deprecated: Use locator-based methods or web assertions instead.
Returns RemotePlaywrightElementHandle \| null
waitForTimeout(timeout)
Wait for the specified timeout.
Discouraged: Use time-based assertions or auto-waiting instead.
waitForFunction(pageFunction, arg?, options?)
Wait for a function to return a truthy value.
Note: Returns a serialized handle reference. Full JSHandle support not yet available.
Returns unknown
waitForEvent(event, optionsOrPredicate?)
Wait for a specific event to fire.
Returns PageEvents[K]
waitForRequest(urlOrPredicate, options?)
Wait for a specific request.
Returns PlaywrightRequest
waitForResponse(urlOrPredicate, options?)
Wait for a specific response.
Returns PlaywrightResponse
Screenshots & PDF
screenshot(options?)
Take a screenshot of the page.
Returns Buffer
pdf(options?)
Generate a PDF of the page (Chromium only).
Returns Buffer
Evaluation
evaluate(pageFunction, arg?)
Evaluate JavaScript in the page context.
Returns R
evaluateHandle(pageFunction, arg?)
Evaluate JavaScript and return a handle to the result.
Returns RemotePlaywrightJSHandle
$eval(selector, pageFunction, arg?)
Find an element matching the selector and evaluate a function on it.
Deprecated: This method does not wait for the element to pass actionability checks. Use locator.evaluate() instead.
Returns T
$$eval(selector, pageFunction, arg?)
Find all elements matching the selector and evaluate a function on the array of elements.
Deprecated: This method does not wait for elements to pass actionability checks. Use locator.evaluateAll() instead.
Returns T
Lifecycle
close(options?)
Close the page.
bringToFront()
Bring page to front (activate tab).
Other
emulateMedia(options?)
Emulate media type, color scheme, etc.
mainFrame()
Get the main frame.
Returns RemotePlaywrightFrame
frames()
Get all frames attached to the page.
Returns RemotePlaywrightFrame[]
frame(frameSelector)
Get a frame by name or URL.
Returns RemotePlaywrightFrame \| null
route(url, handler, options?)
Route requests matching the URL pattern.
unroute(url, handler?)
Remove a route.
unrouteAll(options?)
Remove all routes.
setExtraHTTPHeaders(headers)
Set extra HTTP headers for all requests.
context()
Get the browser context that the page belongs to.
Returns unknown
setDefaultTimeout(timeout)
Set the default timeout for all methods.
setDefaultNavigationTimeout(timeout)
Set the default navigation timeout.
addInitScript(script, arg?)
Add a script to evaluate before page scripts run.
addScriptTag(options)
Add a <script> tag to the page.
Returns RemotePlaywrightElementHandle
addStyleTag(options)
Add a <style> tag to the page.
Returns RemotePlaywrightElementHandle
exposeBinding(name, callback, options?)
Expose a binding to the page (with source info).
pause()
Pause script execution (for debugging).
video()
Get the video object if recording is enabled.
Returns { path: () => Promise<string \| null>; saveAs: (path: string) => Promise<void>; delete: () => Promise<void> } \| null
opener()
Get the page that opened this page (via window.open).
Returns RemotePlaywrightPage \| null
workers()
Get all web workers in the page.
Returns unknown[]
addLocatorHandler(locator, handler, options?)
Registers a handler that will be called when the specified locator becomes visible on the page.
Useful for handling overlays and popups that may appear during automation.
removeLocatorHandler(locator)
Removes a previously added locator handler.
consoleMessages()
Returns all console messages captured during the page lifecycle.
Note: This is a custom method that returns accumulated console messages.
Returns PlaywrightConsoleMessage[]
pageErrors()
Returns all page errors (uncaught exceptions) captured during the page lifecycle.
Note: This is a custom method that returns accumulated page errors.
Returns Error[]
requestGC()
Request garbage collection in the page context.
Note: This method is only available in Chromium-based browsers.
requests()
Returns all requests made by the page since the last navigation.
Note: This is a custom method that returns accumulated requests.
Returns PlaywrightRequest[]
routeFromHAR(har, options?)
Serves network requests from a HAR (HTTP Archive) file.
Useful for replaying recorded network traffic during tests.
routeWebSocket(url, handler)
Route WebSocket connections matching the URL pattern.
Allows intercepting and modifying WebSocket traffic.
Mouse
mouse.click(x, y, options?)
Shortcut for mouse.move(), mouse.down(), mouse.up().
Simulates a mouse click at the specified coordinates.
mouse.up(options?)
Dispatches a mouseup event.
mouse.move(x, y, options?)
Dispatches a mousemove event.
The steps option controls the number of intermediate mousemove events to generate.
mouse.wheel(deltaX, deltaY)
Dispatches a wheel event.
This method is usually used to manually scroll the page. Wheel events may cause scrolling if they are not handled, and this method does not wait for the scrolling to finish before returning.
keyboard.up(key)
Dispatches a keyup event.
keyboard.press(key, options?)
Shortcut for keyboard.down() and keyboard.up().
Dispatches a keydown, keypress/input, and keyup event for the specified key.
If key is a single character and no modifier keys besides Shift are being held down, a keypress/input event will also be generated.
Modifier keys DO affect keyboard.press. Holding down Shift will type the text in upper case.
Shortcut such as “ControlOrMeta+A” are supported. “ControlOrMeta” resolves to “Control” on Windows/Linux and to “Meta” on macOS.

