Skip to content

Events and debugging

Which page events reach your automation client, how to capture console output anyway, and how to check which renderer actually paints the page.

Console and page-error events

The engine does not forward console or page-error events to automation clients, so page.on("console") and page.on("pageerror") receive nothing. That is by design — forwarding them is exactly what an automation-presence probe measures. In-page window.onerror and unhandledrejection handlers fire normally, so to capture console output collect it in-page and read it back with page.evaluate(). The Python, Node and .NET SDKs print a one-time note about this at launch, except when stock_runtime (below) has turned the suppression off.

Two driver calls depend on those events. Playwright's page.setContent() waits for a console event, so it times out (Puppeteer's works): open the HTML as a data: URL, or write it into the page with page.evaluate(). exposeFunction() and exposeBinding(), in Playwright and Puppeteer, work in the page that is open when you call them, and are gone once that page navigates: call them after the last navigation, or pass results back from page.evaluate().

Turn it back on for a debugging run (stock_runtime)

From the licensed 154 r32 build you can turn the suppression off. With SDK 0.41.0 or newer, pass stock_runtime=True (Node stockRuntime: true, .NET StockRuntime = true) or set CLEARCOTE_STOCK_RUNTIME=1, and the standard DevTools Runtime behaviour comes back: page.on("console") and page.on("pageerror") receive events, Playwright's page.setContent() works, and exposeFunction() / exposeBinding() keep working after a navigation. The SDK adds the engine switch, --disable-runtime-suppression, once; with raw Playwright and no SDK, pass that switch in args yourself.

from clearcote import launch

browser = launch(fingerprint="seed-123", stock_runtime=True)   # or CLEARCOTE_STOCK_RUNTIME=1
page = browser.new_page()
page.on("console", lambda msg: print("console:", msg.text))
page.set_content("<script>console.log('hello')</script>")      # works with stock_runtime
browser.close()
  • Off by default. Switching it on restores exactly the signal described above, which pages can observe, so use it while you debug rather than in production. An explicit option wins over the variable (1, true, yes or on turn it on).
  • Needs an engine that has the switch (licensed build from r32). On an older engine or the open build the SDK launches without it and warns once per process; quiet and CLEARCOTE_NO_WARN silence that.
  • Local and Docker launches. A Docker launch hands it to the container, whose entrypoint keeps it only on an engine that has it (its serve-state line reports stock_runtime); in your own docker run, put --disable-runtime-suppression in CC_EXTRA_ARGS. A cloud launch does not apply it and says so once.
from urllib.parse import quote

# Instead of page.set_content(html):
# short HTML: a data: URL (the page gets no origin of its own, so no cookies or storage)
page.goto("data:text/html," + quote(html))
# any HTML: write it into a page you have navigated to; it keeps that page's origin
page.evaluate("html => { document.open(); document.write(html); document.close(); }", html)

Render-backend coherence check (checkRenderCoherence)

A persona can claim a GPU, but if the page is actually painted by a software rasterizer (SwiftShader / llvmpipe — common headless with no GPU) a strict detector can tell. Probe a live page: it reads the (unmasked) WebGL vendor/renderer the page actually sees, flags a software-rasterizer fallback (a fatal headless tell — enable the canvas bridge or run headed on a real GPU) or an incoherent vendor/renderer pair, and returns a structured verdict. Pass the claimed GPU to also assert the rendered family. Available sync, async, and in Node.

from clearcote import launch, check_render_coherence

browser = launch(fingerprint="seed-123")
page = browser.new_page(); page.goto("about:blank")

verdict = check_render_coherence(page)   # {'renderer', 'software_suspected', 'coherent', 'warnings'}
if not verdict["coherent"]:
    print(verdict["warnings"])            # e.g. software rasterizer / incoherent GPU family
browser.close()