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 Server BrowserType

From Leeroopedia
Knowledge Sources
Domains Browser Automation, Browser Lifecycle
Last Updated 2026-02-12 00:00 GMT

Overview

Concrete tool for managing browser type launch and connection on the server side provided by the Playwright library.

Description

The `BrowserType` abstract class extends `SdkObject` and serves as the factory for launching and connecting to browser instances. It manages the browser lifecycle including process launching via `launchProcess`, WebSocket/pipe transport creation, user data directory management, and browser options normalization. Each browser engine (Chromium, Firefox, WebKit) provides its own concrete subclass. The class resolves executable paths through the browser registry, handles proxy settings normalization, client certificate proxy setup, and provides methods for both local launch (`launch`) and remote connection (`connectOverCDP`). It also handles graceful shutdown of browser processes.

Usage

Use this abstract class as the base for browser-specific launch implementations. Concrete subclasses (Chromium, Firefox, WebKit) override the abstract methods to provide engine-specific launch arguments and connection logic.

Code Reference

Source Location

Signature

export abstract class BrowserType extends SdkObject {
  private _name: BrowserName;

  constructor(parent: SdkObject, browserName: BrowserName);
  executablePath(): string;
  name(): string;
  abstract connectToTransport(transport: ConnectionTransport, options: BrowserOptions): Promise<Browser>;
  abstract doRewriteStartupLog(error: ProtocolError): ProtocolError;
}

Import

import { BrowserType } from '../server/browserType';

I/O Contract

Inputs

Name Type Required Description
parent SdkObject Yes Parent SDK object for instrumentation hierarchy
browserName BrowserName Yes Browser engine name (chromium, firefox, webkit)
options LaunchOptions Yes Launch options including headless, proxy, args, env
transport ConnectionTransport Yes Transport for connecting to an existing browser process

Outputs

Name Type Description
Browser Browser Launched or connected browser instance
executablePath string Path to the browser executable

Usage Examples

// Concrete subclass usage (e.g., Chromium)
const chromium = new Chromium(parent, bidiChromium);
const browser = await chromium.launch({
  headless: true,
  proxy: { server: 'http://proxy:8080' },
});

const execPath = chromium.executablePath();
console.log('Browser executable:', execPath);

Related Pages

Page Connections

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