Registry / testing / playwright-core

playwright-core

JSON →
library1.59.1jsnpmunverified

Playwright Core is the foundational JavaScript library for automating web browsers, providing a high-level API to control Chromium, Firefox, and WebKit through a single interface. It is designed for robust end-to-end testing, web scraping, and general browser automation tasks. As of version 1.59.1, the project maintains a rapid release cadence, typically monthly, delivering new features and browser updates. Recent additions include the `page.screencast` API for comprehensive recording capabilities and the introduction of a new CLI mode (`playwright-cli`) for AI agent-friendly, token-efficient operations. Key differentiators of Playwright Core include its auto-waiting functionality, resilient element interaction APIs, and native mobile emulation. While this package provides the raw browser automation API, it commonly serves as the underlying engine for the broader `playwright` package, which integrates a full test runner and pre-built browser binaries. It requires Node.js version 18 or higher to operate.

npm install playwright-core
INSTALL
IMPORT
SIG · PLAYWRIGHT-CORE
P
playwright-core
testingjavascriptv1.59.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

chromium
import { chromium } from 'playwright-core';
const { chromium } = require('playwright-core');
For modern Node.js environments and Playwright versions >= 1.20, ES Modules (`import`) are the primary consumption method. CommonJS (`require`) may lead to `ERR_REQUIRE_ESM`.
Browser, Page
import type { Browser, Page } from 'playwright-core';
import { Browser, Page } from 'playwright-core';
When only importing types for TypeScript, use `import type` to prevent bundling unnecessary runtime code and ensure cleaner type-checking.
firefox, webkit
import { firefox, webkit } from 'playwright-core';
Similar to `chromium`, these are named exports for launching specific browser types directly from the core library.

Demonstrates launching a headless Chromium browser, navigating to multiple pages, taking a screenshot, interacting with an element, and verifying the URL after navigation using Playwright Core.

import { chromium, type Browser, type Page } from 'playwright-core'; import * as fs from 'fs'; async function runBrowserAutomation() { let browser: Browser | undefined; try { // Launch a headless Chromium browser browser = await chromium.launch({ headless: true }); const page: Page = await browser.newPage(); // Navigate to a website await page.goto('https://www.example.com'); console.log('Navigated to example.com'); // Take a screenshot and save it const screenshotPath = 'example_screenshot.png'; await page.screenshot({ path: screenshotPath }); console.log(`Screenshot saved to ${screenshotPath}`); // Get and print the page title const title = await page.title(); console.log(`Page title: "${title}"`); // Navigate to another page and interact with an element await page.goto('https://playwright.dev'); const getStartedButton = page.locator('a', { hasText: 'Get started' }).first(); await getStartedButton.click(); console.log('Clicked "Get started" on Playwright.dev'); // Wait for navigation to complete and verify the URL await page.waitForURL('**/docs/intro'); console.log(`Current URL after click: ${page.url()}`); } catch (error) { console.error('An error occurred during automation:', error); } finally { // Ensure the browser is closed even if an error occurs if (browser) { await browser.close(); console.log('Browser closed.'); } } } runBrowserAutomation();
Debug
Known issues
breakingPlaywright Core dropped support for Chromium extension manifest v2. Projects relying on these older manifest versions for browser extensions will need to update their extensions or browser versions.
fix
Migrate Chromium extensions to Manifest V3. Consult Chromium documentation for migration guides.
affects: >=1.55.0
gotchaThe `playwright-core` package provides only the low-level browser automation API. It does not include the Playwright Test runner or the pre-built browser binaries (Chromium, Firefox, WebKit). Attempting to use `playwright-core` without explicitly installing or managing browser binaries will lead to errors.
fix
For a complete testing solution including test runner and auto-downloaded browsers, install `playwright` (`npm i -D playwright`). If you only need `playwright-core`, ensure you manually install browser binaries using `npx playwright install` or `npx playwright install chromium`.
affects: >=1.0
breakingPlaywright Core requires Node.js version 18 or higher. Running with older Node.js versions will result in execution errors.
fix
Upgrade your Node.js environment to version 18 or newer. Use a Node Version Manager (NVM) for easy switching (e.g., `nvm install 18 && nvm use 18`).
affects: >=1.55.0
gotchaThe console window when spawning browser processes on Windows was reverted from being hidden, which previously caused regressions in features like `codegen`, `--ui`, and `show` commands.
fix
This fix is included in `v1.59.1`. If encountering issues with `codegen`, `--ui`, or `show` commands on Windows with older versions, update to `v1.59.1` or newer. The console window will now be visible during browser spawning on Windows.
affects: >=1.59.1
Errors
Common errors & fixes
ERR_REQUIRE_ESM
Attempting to import `playwright-core` using CommonJS `require()` syntax in an ES Module context, or generally in newer Node.js versions where Playwright is published as an ESM module.
fix
Change your import statements from `const { chromium } = require('playwright-core');` to `import { chromium } from 'playwright-core';`. Ensure your `package.json` specifies `"type": "module"` or use `.mjs` file extensions.
Error: Browser type 'chromium' is not found. Close all running browsers and try again.
The required browser binaries (e.g., Chromium) have not been installed or are corrupted for `playwright-core`.
fix
Run `npx playwright install chromium` to download and install the Chromium browser binaries. For all browsers, use `npx playwright install`.
Error: Node.js v16.x is not supported. Please upgrade to Node.js v18 or higher.
The installed Node.js version is below the minimum requirement for the Playwright Core package.
fix
Upgrade your Node.js environment to version 18 or newer. Use NVM (`nvm install 18 && nvm use 18`) or update through your system's package manager.
TimeoutError: locator.click: Timeout 30000ms exceeded.
The specified element could not be found, was not visible, or was not actionable within the default timeout period.
fix
Ensure the selector is correct and the element is present and visible on the page. Use `page.waitForSelector()` with appropriate state options (`'visible'`, `'attached'`, `'loaded'`) before interacting, or increase the locator's timeout: `page.locator('selector').click({ timeout: 60000 })`.
Upgrade
Version history
1.59.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
5 hits · last 30 days
node
4
Amazon
1
Resources