Skip to main content
BrowserType provides methods to launch or connect to browser instances. Available through playwright.chromium, playwright.firefox, or playwright.webkit.

Inheritance

Extends: ChannelOwner

Methods

executablePath

Returns the path to the browser executable.
Returns: string - Path to the browser executable Throws: Error if the browser is not supported on the current platform

name

Returns the browser name.
Returns: string - Browser name (‘chromium’, ‘firefox’, or ‘webkit’)

launch

Launches a new browser instance.
LaunchOptions
Launch configuration options
  • headless (boolean): Whether to run in headless mode (default: true)
  • executablePath (string): Path to browser executable
  • args (string[]): Additional arguments to pass to the browser
  • ignoreDefaultArgs (boolean | string[]): Ignore default arguments
  • channel (string): Browser channel to use
  • env (object): Environment variables
  • slowMo (number): Slows down operations by specified milliseconds
  • timeout (number): Maximum time in milliseconds to wait for browser to start
  • logger (Logger): Logger instance
Returns: Promise<Browser> - Browser instance

launchPersistentContext

Launches browser with persistent storage.
string
required
Path to user data directory for persistent storage
LaunchPersistentContextOptions
Launch options combined with context options
Returns: Promise<BrowserContext> - Browser context with persistent storage

connect

Connects to a running browser instance.
ConnectOptions
required
Connection options
  • wsEndpoint (string): WebSocket endpoint to connect to
  • timeout (number): Maximum time to wait for connection
  • slowMo (number): Slows down operations by specified milliseconds
  • headers (object): Additional HTTP headers
  • logger (Logger): Logger instance
Returns: Promise<Browser> - Connected browser instance

connectOverCDP

Connects to a browser over Chrome DevTools Protocol.
string
required
CDP endpoint URL (ws:// or http://)
ConnectOverCDPOptions
CDP connection options
  • timeout (number): Connection timeout
  • slowMo (number): Slow down operations
  • headers (object): Additional headers
  • logger (Logger): Logger instance
Returns: Promise<Browser> - Connected browser Note: Only supported for Chromium browsers

launchServer

Launches a browser server.
LaunchServerOptions
Server launch options
Returns: Promise<BrowserServer> - Browser server instance

Usage Examples

Launch Browser

Connect to Remote Browser

Launch with Persistent Context

Connect Over CDP