AI agent instructions
AI agent instructions
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
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: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, usesession.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: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.
session.page (which is already Playwright-compatible) is sufficient.
Migrating from Selenium
Notte sessions are driven over CDP, so Playwright (orsession.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