cdp_playwright.py
Returns
str: The WebSocket URL for the Chrome DevTools Protocol.
Raises
ValueError: If the session hasn’t been started yet (no session_id available).
Get the Chrome DevTools Protocol WebSocket URL for the session
from notte_sdk import NotteClient
from patchright.sync_api import sync_playwright
client = NotteClient()
with client.Session(proxies=False) as session:
# get cdp url
cdp_url = session.cdp_url()
with sync_playwright() as p:
browser = p.chromium.connect_over_cdp(cdp_url)
page = browser.contexts[0].pages[0]
_ = page.goto("https://www.google.com")
screenshot = page.screenshot(path="screenshot.png")
assert screenshot is not None
str: The WebSocket URL for the Chrome DevTools Protocol.
ValueError: If the session hasn’t been started yet (no session_id available).Was this page helpful?
Suggestions