AI agent instructions
AI agent instructions
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].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