Playwright Browser

View as Markdown

All Browser methods available when using the Playwright driver.

Access via runtime.browser after launching a Playwright runtime.

Every method below is a remote call. The SDK translates it into a structured step sent to a single endpoint:

POST /v1/workspaces/{workspaceId}/execute
1{
2 "runtime": "my-browser",
3 "steps": [
4 {
5 "call": "browser.goto",
6 "args": ["https://example.com"]
7 }
8 ]
9}

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.

State Checks

isConnected()

Indicates that the browser is connected.

Note: This is async in the remote SDK, unlike the native Playwright API.

1await runtime.browser.isConnected();

Returns boolean

Upstream docs


Lifecycle

contexts()

Returns an array of all open browser contexts.

In a newly created browser, this will return zero browser contexts. Note: This is async in the remote SDK, unlike the native Playwright API.

1await runtime.browser.contexts();

Returns RemotePlaywrightBrowserContext[]

Upstream docs


newContext(options?)

Creates a new browser context. It will not share cookies/cache with other browser contexts.

If directly using this method to create BrowserContexts, it is best practice to explicitly close the returned context via browserContext.close() when your code is done with the BrowserContext, and before calling browser.close().

1await runtime.browser.newContext();
ParameterTypeRequiredDescription
optionsPlaywrightNewContextOptionsNo

Returns RemotePlaywrightBrowserContext

Upstream docs


newPage(options?)

Creates a new page in a new browser context. Closing this page will close the context as well.

This is a convenience API that should only be used for single-page scenarios and short snippets. Production code and testing frameworks should explicitly create browser.newContext() followed by browserContext.newPage() to control their exact life times.

1await runtime.browser.newPage();
ParameterTypeRequiredDescription
optionsPlaywrightNewPageOptionsNo

Returns RemotePlaywrightPage

Upstream docs


close(options?)

Closes the browser and all of its pages (if any were opened).

The Browser object itself is considered to be disposed and cannot be used anymore. This is similar to force-quitting the browser.

1await runtime.browser.close();
ParameterTypeRequiredDescription
options{ reason?: string }No

Upstream docs


Other

browserType()

Get the browser type name (chromium, firefox, or webkit) that was used to launch this browser.

Note: Returns the name string. This is async in the remote SDK, unlike the native Playwright API.

1await runtime.browser.browserType();

Returns 'chromium' \| 'firefox' \| 'webkit'

Upstream docs


version()

Returns the browser version.

Note: This is async in the remote SDK, unlike the native Playwright API.

1await runtime.browser.version();

Returns string

Upstream docs


newBrowserCDPSession()

Returns the newly created browser session.

CDP Sessions are only supported on Chromium-based browsers.

1await runtime.browser.newBrowserCDPSession();

Returns { sessionId: string }

Upstream docs


startTracing(page?, options?)

Starts Chromium Tracing.

This is a Chromium-only API. Only one trace can be active at a time per browser.

1await runtime.browser.startTracing();
ParameterTypeRequiredDescription
pageHasHandleIdNoOptional page to capture screenshots from.
optionsPlaywrightStartTracingOptionsNoTracing options.

Upstream docs


stopTracing()

Stops Chromium Tracing and returns the trace data.

This is a Chromium-only API. Returns the trace data as a Buffer.

1await runtime.browser.stopTracing();

Returns Buffer

Upstream docs