Skip to main content
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.

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].

Use Both Notte and Playwright APIs

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

Async Playwright Support

Notte works with both sync and async Playwright:

Advanced: Multiple Pages and Contexts

Create additional pages or contexts using Playwright:

Network Interception

Use Playwright’s powerful network interception with Notte sessions:

Browser Events and Monitoring

Listen to browser events using Playwright:

Best Practices

1. Use Context Managers

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

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 custom contexts.

3. Session Timeout

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

4. Handle CDP Disconnections

CDP connections can be interrupted. Wrap operations in try-except blocks:
playwright_cdp_error_handling.py

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 contexts: Separate browser contexts with different settings
  • Custom browser settings: Specific viewport, user agent, or permissions per context
  • 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.

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

External Providers

Connect to Kernel.sh and other providers