Skip to main content

Embed a Managed Browser Live View

Hosted applications cannot embed the native window opened by --head. Instead, run Chromium with a managed browser provider, connect Testronaut over Chrome DevTools Protocol (CDP), and give your application a temporary live-view URL.

Testronaut supports this integration through environment variables. Local missions remain unchanged when these variables are absent.

Availability

Managed remote-browser support is newer than Testronaut 2.2.1. Use a release that includes managed browser live views. The local --head flag in 2.2.1 does not provide remote CDP or iframe streaming by itself.

Connect to managed Chromium​

Set TESTRONAUT_BROWSER_WS_ENDPOINT to the provider's private WebSocket CDP endpoint before starting the mission:

export TESTRONAUT_BROWSER_WS_ENDPOINT="wss://production-sfo.browserless.io/chromium?token=$BROWSERLESS_TOKEN"
testronaut missions/checkout.mission.js

When this variable is present, Testronaut uses Playwright's chromium.connectOverCDP() instead of launching local Chromium. Keep the endpoint server-side: it normally contains a provider credential with full browser control.

Request a live-view URL​

Choose a private file path that both Testronaut and your server-side orchestrator can access:

export TESTRONAUT_LIVE_VIEW_PATH="/tmp/testronaut-live-view.json"
export TESTRONAUT_LIVE_VIEW_INTERACTABLE="false"
testronaut missions/checkout.mission.js

After connecting, Testronaut asks Browserless for a temporary Live URL and writes a descriptor like this with owner-only file permissions:

{
"liveURL": "https://production-sfo.browserless.io/e/.../live/...",
"interactable": false,
"createdAt": "2026-11-30T18:00:00.000Z"
}

The URL is deliberately written to a file rather than stdout so it does not appear in ordinary CLI logs, reports, or log drains. Read the file from the server-side process supervising the mission, authorize the requesting user, then send only the temporary Live URL to that user.

Embed the view​

Allow the selected Browserless region in the parent application's Content Security Policy and render the URL in a sandboxed iframe:

Content-Security-Policy: frame-src 'self' https://production-sfo.browserless.io
<iframe
src="TEMPORARY_LIVE_URL"
title="Live browser session"
sandbox="allow-same-origin allow-scripts"
referrerpolicy="no-referrer">
</iframe>

With TESTRONAUT_LIVE_VIEW_INTERACTABLE=false, Browserless rejects viewer mouse and keyboard input on the server. A client cannot turn the view into an interactive session by removing an overlay or changing CSS.

Security checklist​

  • Store the provider token in a secret manager and inject it only into the private mission runner.
  • Never return TESTRONAUT_BROWSER_WS_ENDPOINT to a browser client or include it in mission events.
  • Treat the temporary Live URL as a bearer credential. Deliver it only through a run-scoped, authenticated channel.
  • Set TESTRONAUT_LIVE_VIEW_INTERACTABLE=false explicitly for observation.
  • Restrict frame-src to the exact managed-browser region you use.
  • Clear the live URL from application state when the mission ends and bound stored mission/event data with an expiration policy.
  • Review privacy disclosures because the stream can show information visible on the automated page.

Human takeover​

A read-only live view does not pause Testronaut. Setting TESTRONAUT_LIVE_VIEW_INTERACTABLE=true gives the viewer browser input, but it does not coordinate that input with agent actions. Do not enable it as an ad-hoc takeover mechanism: human clicks and agent actions can race.

A production takeover flow needs an exclusive control lease, a pause at an agent tool boundary, an interactive URL issued only while paused, and a DOM refresh before returning control to the agent. Until an orchestrator implements that protocol, use view-only mode plus the manual input tool or a human-action handoff.

How this differs from --head​

ModeBrowser locationViewerIntended use
DefaultLocal, headlessNoneCI and unattended missions
--head / --headedLocal desktopNative windowWatch a CLI run on the same machine
Managed CDP + Live URLProvider infrastructureHosted iframeEmbed a run in a web product

See Headed Browser Mode for local desktop usage.