Skip to main content
Playwright is the main entry point for all browser automation. It provides access to browser types (Chromium, Firefox, WebKit), devices, and utilities.

Inheritance

Extends: ChannelOwner

Properties

chromium

chromium
BrowserType
BrowserType instance for launching or connecting to Chromium browsers.

firefox

firefox
BrowserType
BrowserType instance for launching or connecting to Firefox browsers.

webkit

webkit
BrowserType
BrowserType instance for launching or connecting to WebKit browsers.

devices

devices
object
Registry of device descriptors for mobile emulation. Contains pre-configured settings for popular devices.

selectors

selectors
Selectors
Selectors engine instance for customizing element selection behavior.

request

request
APIRequest
API request context for making HTTP requests outside of a browser context.

errors

errors
object
Object containing Playwright-specific error classes.
  • TimeoutError: Thrown when operations exceed their timeout

Usage Examples

Basic Browser Launch

import { chromium, firefox, webkit } from 'playwright';

// Launch Chromium
const browser = await chromium.launch();
const page = await browser.newPage();
await page.goto('https://example.com');

// Launch Firefox
const firefoxBrowser = await firefox.launch({ headless: false });

// Launch WebKit
const webkitBrowser = await webkit.launch();

Using Device Emulation

import { chromium, devices } from 'playwright';

const browser = await chromium.launch();
const iPhoneDevice = devices['iPhone 13'];
const context = await browser.newContext({
  ...iPhoneDevice,
});
const page = await context.newPage();

Making API Requests

import { request } from 'playwright';

const apiContext = await request.newContext({
  baseURL: 'https://api.example.com',
});

const response = await apiContext.get('/endpoint');
const data = await response.json();

Build docs developers (and LLMs) love