Skip to main content
Page other methods for the Playwright driver.

setViewportSize

Set the viewport size. Upstream docs
viewportSize
PlaywrightViewportSize
required
await page.setViewportSize(/* PlaywrightViewportSize */);

emulateMedia

Emulate media type, color scheme, etc. Upstream docs
options
PlaywrightEmulateMediaOptions
await page.emulateMedia();

mainFrame

Get the main frame. Upstream docs
result
string
Return value
await page.mainFrame();

frames

Get all frames attached to the page. Upstream docs
result
RemotePlaywrightFrame[]
Return value
await page.frames();

frame

Get a frame by name or URL. Upstream docs
frameSelector
string | { name?: string; url?: string | RegExp | ((url: URL) => boolean) }
required
result
RemotePlaywrightFrame | null
Return value
await page.frame(/* string | { name?: string; url?: string | RegExp | ((url: URL) => boolean) } */);

route

Route requests matching the URL pattern. Upstream docs
url
string | RegExp | ((url: URL) => boolean)
required
handler
PlaywrightRouteHandler
required
options
{ times?: number }
await page.route(/* string | RegExp | ((url: URL) => boolean) */, /* PlaywrightRouteHandler */);

unroute

Remove a route. Upstream docs
url
string | RegExp | ((url: URL) => boolean)
required
handler
PlaywrightRouteHandler
await page.unroute(/* string | RegExp | ((url: URL) => boolean) */);

unrouteAll

Remove all routes. Upstream docs
options
{ behavior?: "wait" | "ignoreErrors" | "default" }
await page.unrouteAll();

setExtraHTTPHeaders

Set extra HTTP headers for all requests. Upstream docs
headers
Record<string, string>
required
await page.setExtraHTTPHeaders(/* Record<string, string> */);

context

Get the browser context that the page belongs to. Upstream docs
result
unknown
Return value
await page.context();

setDefaultTimeout

Set the default timeout for all methods. Upstream docs
timeout
number
required
await page.setDefaultTimeout(0);

setDefaultNavigationTimeout

Set the default navigation timeout. Upstream docs
timeout
number
required
await page.setDefaultNavigationTimeout(0);

addInitScript

Add a script to evaluate before page scripts run. Upstream docs
script
string | { path?: string; content?: string }
required
arg
unknown
await page.addInitScript(/* string | { path?: string; content?: string } */);

addScriptTag

Add a <script> tag to the page. Upstream docs
options
PlaywrightAddScriptTagOptions
required
result
RemotePlaywrightElementHandle
Return value
await page.addScriptTag(/* PlaywrightAddScriptTagOptions */);

addStyleTag

Add a <style> tag to the page. Upstream docs
options
PlaywrightAddStyleTagOptions
required
result
RemotePlaywrightElementHandle
Return value
await page.addStyleTag(/* PlaywrightAddStyleTagOptions */);

exposeBinding

Expose a binding to the page (with source info). Upstream docs
name
string
required
callback
string
required
options
{ handle?: boolean }
await page.exposeBinding('...', '...');

pause

Pause script execution (for debugging). Upstream docs
await page.pause();

video

Get the video object if recording is enabled. Upstream docs
result
{ path: () => Promise<string | null>; saveAs: (path: string) => Promise<void>; delete: () => Promise<void> } | null
Return value
await page.video();

opener

Get the page that opened this page (via window.open). Upstream docs
result
RemotePlaywrightPage | null
Return value
await page.opener();

workers

Get all web workers in the page. Upstream docs
result
unknown[]
Return value
await page.workers();

addLocatorHandler

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.
Upstream docs
locator
RemotePlaywrightLocator
required
handler
(locator: RemotePlaywrightLocator) => Promise<void>
required
options
PlaywrightAddLocatorHandlerOptions
await page.addLocatorHandler(/* RemotePlaywrightLocator */, /* (locator: RemotePlaywrightLocator) => Promise<void> */);

removeLocatorHandler

Removes a previously added locator handler. Upstream docs
locator
RemotePlaywrightLocator
required
await page.removeLocatorHandler(/* RemotePlaywrightLocator */);

consoleMessages

Returns all console messages captured during the page lifecycle.
Note: This is a custom method that returns accumulated console messages.
Upstream docs
result
PlaywrightConsoleMessage[]
Return value
await page.consoleMessages();

pageErrors

Returns all page errors (uncaught exceptions) captured during the page lifecycle.
Note: This is a custom method that returns accumulated page errors.
Upstream docs
result
Error[]
Return value
await page.pageErrors();

requestGC

Request garbage collection in the page context.
Note: This method is only available in Chromium-based browsers.
Upstream docs
await page.requestGC();

requests

Returns all requests made by the page since the last navigation.
Note: This is a custom method that returns accumulated requests.
Upstream docs
result
PlaywrightRequest[]
Return value
await page.requests();

routeFromHAR

Serves network requests from a HAR (HTTP Archive) file.
Useful for replaying recorded network traffic during tests.
Upstream docs
har
string
required
options
PlaywrightRouteFromHAROptions
await page.routeFromHAR('...');

routeWebSocket

Route WebSocket connections matching the URL pattern.
Allows intercepting and modifying WebSocket traffic.
Upstream docs
url
string | RegExp | ((url: URL) => boolean)
required
handler
(ws: PlaywrightWebSocketRoute) => void | Promise<void>
required
await page.routeWebSocket(/* string | RegExp | ((url: URL) => boolean) */, /* (ws: PlaywrightWebSocketRoute) => void | Promise<void> */);