Implementation:Microsoft Playwright Client Types
Appearance
| Knowledge Sources | |
|---|---|
| Domains | Browser Automation, Type System |
| Last Updated | 2026-02-12 00:00 GMT |
Overview
Concrete tool for defining shared TypeScript type definitions used throughout the Playwright client API provided by the Playwright library.
Description
This module is the central type definition file for the Playwright client layer. It exports and re-exports numerous types used across the client API:
- Logger: Interface with
isEnabled(name, severity)andlog(name, severity, message, args, hints)for custom logging. - Timeout/Options types:
TimeoutOptions,StrictOptions,WaitForEventOptions,WaitForFunctionOptions,SelectOption,SelectOptionOptions. - Data types:
Headers(string-to-string map),FilePayload(name, mimeType, buffer),StorageState,SetStorageState. - Lifecycle:
LifecycleEventtype andkLifecycleEventsset ('load', 'domcontentloaded', 'networkidle', 'commit'). - Client certificates:
ClientCertificatetype with origin, cert/key/pfx paths and buffers, passphrase. - Browser context options:
BrowserContextOptionsextending channel options with client-friendly types for viewport, headers, logger, storage state, HAR recording, color scheme, and more. - Launch options:
LaunchOptions,LaunchPersistentContextOptions,LaunchServerOptionswith overrides for ignoreDefaultArgs, env, logger, and firefoxUserPrefs. - Connect options:
ConnectOptionsfor connecting to remote browsers. - Selector engine:
SelectorEngineinterface withquery()andqueryAll()methods. - Network types:
RemoteAddr,SecurityDetails,FrameExpectParams. - Geometry re-exports:
HeadersArray,Point,Quad,Rect,Size.
Usage
Import these types throughout the Playwright client codebase for type-safe API definitions, parameter validation, and IDE support.
Code Reference
Source Location
- Repository: Microsoft_Playwright
- File:
packages/playwright-core/src/client/types.ts
Signature
export interface Logger {
isEnabled(name: string, severity: LoggerSeverity): boolean;
log(name: string, severity: LoggerSeverity, message: string | Error, args: any[], hints: { color?: string }): void;
}
export type TimeoutOptions = { timeout?: number };
export type StrictOptions = { strict?: boolean };
export type Headers = { [key: string]: string };
export type WaitForEventOptions = Function | TimeoutOptions & { predicate?: Function };
export type WaitForFunctionOptions = TimeoutOptions & { polling?: 'raf' | number };
export type SelectOption = { value?: string; label?: string; index?: number; valueOrLabel?: string };
export type FilePayload = { name: string; mimeType: string; buffer: Buffer };
export type StorageState = { cookies: NetworkCookie[]; origins: OriginStorage[] };
export type LifecycleEvent = channels.LifecycleEvent;
export type ClientCertificate = { origin: string; cert?: Buffer; certPath?: string; key?: Buffer; keyPath?: string; pfx?: Buffer; pfxPath?: string; passphrase?: string };
export type BrowserContextOptions = { /* extended browser context options */ };
export type LaunchOptions = { /* browser launch options */ };
export type LaunchServerOptions = LaunchOptions & { host?: string; port?: number; wsPath?: string };
export type ConnectOptions = { wsEndpoint: string; headers?: Headers; slowMo?: number; timeout?: number; logger?: Logger };
export type SelectorEngine = { query(root: HTMLElement, selector: string): HTMLElement | null; queryAll(root: HTMLElement, selector: string): HTMLElement[] };
Import
import type { Logger, Headers, BrowserContextOptions, LaunchOptions, TimeoutOptions } from 'playwright-core/src/client/types';
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| (none) | N/A | N/A | This module only exports type definitions and constants |
Outputs
| Name | Type | Description |
|---|---|---|
| kLifecycleEvents | Set<LifecycleEvent> |
Set containing the valid lifecycle event names: 'load', 'domcontentloaded', 'networkidle', 'commit' |
| (types) | Various | TypeScript type definitions for use across the Playwright client |
Usage Examples
import type { BrowserContextOptions, LaunchOptions, Logger } from 'playwright-core/src/client/types';
// Custom logger implementation
const myLogger: Logger = {
isEnabled(name, severity) {
return severity === 'error' || severity === 'warning';
},
log(name, severity, message, args, hints) {
console.log(`[${name}:${severity}] ${message}`);
},
};
// Use types for configuration
const launchOptions: LaunchOptions = {
headless: true,
logger: myLogger,
};
const contextOptions: BrowserContextOptions = {
viewport: { width: 1280, height: 720 },
colorScheme: 'dark',
extraHTTPHeaders: { 'X-Custom': 'value' },
};
Related Pages
Page Connections
Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment