Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Microsoft Playwright CrPage

From Leeroopedia
Revision as of 11:36, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Microsoft_Playwright_CrPage.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Sources
Domains Page Automation, Chrome DevTools Protocol
Last Updated 2026-02-12 00:00 GMT

Overview

Concrete tool for Chromium page-level automation via CDP provided by the Playwright library.

Description

The `CRPage` class implements the `PageDelegate` interface for Chromium browsers using the Chrome DevTools Protocol. It is the largest and most complex page delegate implementation, managing frame sessions (`FrameSession`) for out-of-process iframe (OOPIF) support, the `CRNetworkManager` for network handling, `CRCoverage` for code coverage, `DragManager` for drag-and-drop, and `CRPDF` for PDF generation. Each frame can have its own `FrameSession` with independent CDP sessions, execution contexts, and lifecycle tracking. The class handles dialog events, console messages, JavaScript evaluation, file chooser interception, screencast, media emulation, viewport management, and screenshot capture through CDP commands.

Usage

Use this class as the CDP backend for page operations in Chromium. It is created by `CRBrowserContext` when a new page target is attached and provides the bridge between Playwright's abstract page model and CDP protocol commands.

Code Reference

Source Location

Signature

export class CRPage implements PageDelegate {
  readonly utilityWorldName: string;
  readonly _mainFrameSession: FrameSession;
  readonly _sessions: Map<Protocol.Target.TargetID, FrameSession>;
  readonly _page: Page;
  readonly rawMouse: RawMouseImpl;
  readonly rawKeyboard: RawKeyboardImpl;
  readonly rawTouchscreen: RawTouchscreenImpl;
  readonly _targetId: string;
  readonly _opener: CRPage | null;
  readonly _networkManager: CRNetworkManager;

  constructor(crSession: CRSession, targetId: string, browserContext: CRBrowserContext, opener: CRPage | null, bits: { hasUIWindow: boolean, isBackgroundPage: boolean });
}

Import

import { CRPage } from '../server/chromium/crPage';

I/O Contract

Inputs

Name Type Required Description
crSession CRSession Yes CDP session for this page target
targetId string Yes CDP target ID for this page
browserContext CRBrowserContext Yes Browser context this page belongs to
opener CRPage or null Yes The page that opened this page, if any
bits.hasUIWindow boolean Yes Whether this page has a visible UI window
bits.isBackgroundPage boolean Yes Whether this is a background extension page

Outputs

Name Type Description
_page Page The Playwright Page instance backed by this delegate
screenshots Buffer Screenshot data captured via CDP
PDF Buffer PDF data generated via CDP printing
coverage CRCoverage Code coverage data from the page

Usage Examples

// Created internally by CRBrowser when a target is attached
const crPage = new CRPage(crSession, targetId, browserContext, openerPage, {
  hasUIWindow: true,
  isBackgroundPage: false,
});

// Used via the Page abstraction
const page = crPage._page;
await page.goto('https://example.com');
const screenshot = await page.screenshot();
const pdf = await page.pdf({ format: 'A4' });

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment