Implementation:Microsoft Playwright Server Playwright
Overview
Server Playwright is the root server-side object that creates and holds references to all browser type instances (Chromium, Firefox, WebKit), the Android and Electron drivers, and the debug controller.
Description
The Playwright class extends SdkObject and serves as the top-level entry point for the server side of Playwright. It instantiates all supported browser types (Chromium, Firefox, WebKit), as well as Electron and Android drivers. It tracks all open browsers and pages through instrumentation listeners, and provides methods to enumerate them.
The factory function createPlaywright creates new instances with specified options including SDK language and server mode flags.
Usage
Created once per Playwright server instance. All browser launches originate from this object's browser type properties.
Code Reference
Source Location
packages/playwright-core/src/server/playwright.ts (79 lines)
Class Signature
export class Playwright extends SdkObject {
readonly chromium: BrowserType;
readonly firefox: BrowserType;
readonly webkit: BrowserType;
readonly android: Android;
readonly electron: Electron;
readonly options: PlaywrightOptions;
readonly debugController: DebugController;
constructor(options: PlaywrightOptions)
allBrowsers(): Browser[]
allPages(): Page[]
}
export function createPlaywright(options: PlaywrightOptions): Playwright
Import
import { Playwright, createPlaywright } from './server/playwright';
I/O Contract
Inputs
options.sdkLanguage: Language-- the client SDK languageoptions.isInternalPlaywright?: boolean-- whether this is an internal instanceoptions.isServer?: boolean-- whether running in server mode
Outputs
- Browser type instances for Chromium, Firefox, WebKit
- Android and Electron driver instances
- Debug controller for inspector integration
Related Pages
- Microsoft_Playwright_Server_Instrumentation -- SdkObject base class
- Microsoft_Playwright_WebKit_BrowserType -- WebKit browser type implementation
- Microsoft_Playwright_LaunchApp -- App launcher using browser types