Skip to main content
Read the Notte skill and follow its setup instructions when setting up Notte or building browser automation. This is the shared source for CLI setup, authentication, and the browser-to-code workflow.
Notte sessions expose a Chrome DevTools Protocol (CDP) endpoint that you can connect to with Playwright. This allows you to use Playwright’s API directly while still benefiting from Notte’s cloud infrastructure, anti-detection features, and session management.

Connection URLs and recordings

playwright_url is optional and defaults to None in Python. In a server response it can be absent or null. The field prepares the SDK contract for servers that offer Playwright-protocol access; it does not enable that endpoint. When your server supplies a URL, use the Playwright client version supported by that server. The CDP examples below and the SDK’s page helper continue to use CDP. With CDP, Playwright runs the browser-action logic on your machine and exchanges CDP commands with the remote browser. With Playwright protocol, that logic runs beside the browser, which can reduce network round trips for actions such as clicks and fills. The benefit depends on your network latency and workload; website loading and data transfer still take time. Use the Sessions API or the SDK’s session context manager to stop the session when your automation finishes.

Prerequisites

Install Playwright alongside the Notte SDK:

Connect Playwright to Notte Session

Get the CDP URL from a Notte session and connect Playwright to it:
Notte sessions automatically create a browser context with one page. Access it via browser.contexts[0].pages[0].

Connect with a Single URL

If your code or a third-party tool only takes a WebSocket URL, connect to wss://api.notte.cc/sessions/connect without calling the SDK. Connecting starts a new session and closing the connection stops it, within a few seconds. The TypeScript example uses playwright-core (npm install playwright-core):
  • Pass flat session options as query parameters, such as proxies, max_duration_minutes, idle_timeout_minutes, viewport_width, viewport_height, solve_captchas, block_ads, dialog_policy, and user_agent.
  • Options that take objects or lists, such as profile, proxy lists, and extra_http_headers, are not supported here. record_session and log_session are also refused. Use the SDK or POST /sessions/start for those.
  • The connection returns the session ID in the X-Session-Id header of the WebSocket handshake.
  • Unknown parameter names are ignored, so a misspelled option silently falls back to its default. Check the session’s settings with the session ID if they matter.
  • A rejected connection, such as a bad API key, an invalid value, or a refused option, returns 403 with an empty body. Start with a minimal URL and add parameters one at a time.
  • The URL contains your API key. Don’t log it or share it.

Use Both Notte and Playwright APIs

You can use both the Notte session API and Playwright simultaneously:

Async Playwright Support

NotteClient provides sync operations and a sync Playwright page through session.page. For async operations and async Playwright, use AsyncNotteClient with async with client.Session() and await session.page:

Advanced: Multiple Pages

Open additional pages in the session’s existing browser context:
Each Notte session runs a single browser context. Creating new contexts with browser.new_context() is not supported over the CDP connection; use browser.contexts[0] and open pages in it. To run with different settings (viewport, user agent), start a separate session with those options.

Network Interception

Use Playwright’s powerful network interception with Notte sessions:

Browser Events and Monitoring

Listen to browser events using Playwright:

Handle JavaScript Dialogs

The dialog_policy session option decides who answers JavaScript dialogs (alert, confirm, prompt and beforeunload):
  • auto (default): Notte answers them. It dismisses alert, confirm and prompt, and accepts beforeunload.
  • client: Notte leaves them for your own CDP client (Playwright, Puppeteer or raw CDP) to accept or dismiss.
To answer dialogs yourself, start the session with dialog_policy="client" and register a dialog handler before the page opens one:
With client, a dialog nobody answers within 10 seconds is dismissed (beforeunload is accepted), so a forgotten dialog cannot freeze the session. While a dialog is open the page is blocked: Notte’s own page actions on the session, such as execute() or scrape(), wait until the dialog is answered or the 10 seconds pass. During a Notte agent run on the session, Notte answers dialogs itself. The option applies to Notte-hosted browsers and to external browsers connected with cdp_url.

Best Practices

1. Use Context Managers

Always use context managers for both Notte and Playwright to ensure proper cleanup:

2. Prefer Notte’s Built-in Page

For simple automation, use session.page directly. Only connect Playwright when you need advanced features like network interception or event monitoring.

3. Session Timeout

Remember that Notte sessions have a timeout. For long-running Playwright operations, increase the timeout:

4. Handle CDP Disconnections

CDP connections can be interrupted. Wrap operations in try-except blocks. A connection can also drop before it is established, with socket hang up or ECONNRESET. Connecting again right away usually works, so retry such a failure once after a short delay. Don’t retry an HTTP answer such as 403, 410 or 503: connecting again gets the same answer. session.page already retries this way; the example below does it for a connection you open yourself:

When to Use Playwright with Notte

Use Playwright directly when you need:
  • Network interception: Block resources, modify requests/responses
  • Advanced event monitoring: Console logs, network events, page errors
  • Multiple pages: Drive several tabs of the same session in parallel
  • Playwright’s testing utilities: Screenshots with full-page scrolling, PDF generation, etc.
For most automation tasks, session.page (which is already Playwright-compatible) is sufficient.

Migrating from Selenium

Notte sessions are driven over CDP, so Playwright (or session.page, which is already a Playwright page) is the recommended way to port existing Selenium scripts. Here is a quick comparison:

Next Steps

Connect with Puppeteer

Use Puppeteer with Notte sessions

External Browser Providers

Connect Notte to Kernel.sh and other providers

Session Configuration

Configure session settings and features