{"id":16178,"library":"playwright-core","title":"Playwright Core","description":"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.","status":"active","version":"1.59.1","language":"javascript","source_language":"en","source_url":"https://github.com/microsoft/playwright","tags":["javascript","typescript"],"install":[{"cmd":"npm install playwright-core","lang":"bash","label":"npm"},{"cmd":"yarn add playwright-core","lang":"bash","label":"yarn"},{"cmd":"pnpm add playwright-core","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"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`.","wrong":"const { chromium } = require('playwright-core');","symbol":"chromium","correct":"import { chromium } from 'playwright-core';"},{"note":"When only importing types for TypeScript, use `import type` to prevent bundling unnecessary runtime code and ensure cleaner type-checking.","wrong":"import { Browser, Page } from 'playwright-core';","symbol":"Browser, Page","correct":"import type { Browser, Page } from 'playwright-core';"},{"note":"Similar to `chromium`, these are named exports for launching specific browser types directly from the core library.","symbol":"firefox, webkit","correct":"import { firefox, webkit } from 'playwright-core';"}],"quickstart":{"code":"import { chromium, type Browser, type Page } from 'playwright-core';\nimport * as fs from 'fs';\n\nasync function runBrowserAutomation() {\n  let browser: Browser | undefined;\n  try {\n    // Launch a headless Chromium browser\n    browser = await chromium.launch({ headless: true });\n    const page: Page = await browser.newPage();\n\n    // Navigate to a website\n    await page.goto('https://www.example.com');\n    console.log('Navigated to example.com');\n\n    // Take a screenshot and save it\n    const screenshotPath = 'example_screenshot.png';\n    await page.screenshot({ path: screenshotPath });\n    console.log(`Screenshot saved to ${screenshotPath}`);\n\n    // Get and print the page title\n    const title = await page.title();\n    console.log(`Page title: \"${title}\"`);\n\n    // Navigate to another page and interact with an element\n    await page.goto('https://playwright.dev');\n    const getStartedButton = page.locator('a', { hasText: 'Get started' }).first();\n    await getStartedButton.click();\n    console.log('Clicked \"Get started\" on Playwright.dev');\n\n    // Wait for navigation to complete and verify the URL\n    await page.waitForURL('**/docs/intro');\n    console.log(`Current URL after click: ${page.url()}`);\n\n  } catch (error) {\n    console.error('An error occurred during automation:', error);\n  } finally {\n    // Ensure the browser is closed even if an error occurs\n    if (browser) {\n      await browser.close();\n      console.log('Browser closed.');\n    }\n  }\n}\n\nrunBrowserAutomation();\n","lang":"typescript","description":"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."},"warnings":[{"fix":"Migrate Chromium extensions to Manifest V3. Consult Chromium documentation for migration guides.","message":"Playwright 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.","severity":"breaking","affected_versions":">=1.55.0"},{"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`.","message":"The `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.","severity":"gotcha","affected_versions":">=1.0"},{"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`).","message":"Playwright Core requires Node.js version 18 or higher. Running with older Node.js versions will result in execution errors.","severity":"breaking","affected_versions":">=1.55.0"},{"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.","message":"The 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.","severity":"gotcha","affected_versions":">=1.59.1"}],"env_vars":null,"search_vec":"'1.59.1':50 '18':152 'addit':67 'agent':90 'agent-friend':89 'ai':88 'api':19,71,110,123 'auto':104 'auto-wait':103 'autom':11,45,122 'binari':147 'broader':133 'browser':13,44,64,121,146 'built':145 'cadenc':57 'capabl':75 'chromium':22 'cli':82,86 'common':125 'comprehens':73 'control':21 'core':2,4,100 'deliv':60 'design':32 'differenti':97 'effici':94 'element':108 'emul':114 'end':36,38 'end-to-end':35 'engin':130 'featur':62 'firefox':23 'foundat':7 'friend':91 'full':139 'function':106 'general':43 'high':17 'high-level':16 'higher':154 'includ':68,101 'integr':137 'interact':109 'interfac':29 'introduct':78 'javascript':8,157 'key':96 'level':18 'librari':9 'maintain':53 'mobil':113 'mode':83 'month':59 'nativ':112 'new':61,81 'node.js':150 'oper':95,156 'packag':117,135 'page.screencast':70 'playwright':1,3,85,99,134 'playwright-c':84 'pre':144 'pre-built':143 'project':52 'provid':14,118 'rapid':55 'raw':120 'recent':66 'record':74 'releas':56 'requir':149 'resili':107 'robust':34 'runner':141 'scrape':41 'serv':126 'singl':28 'task':46 'test':39,140 'token':93 'token-effici':92 'typescript':158 'typic':58 'under':129 'updat':65 'version':49,151 'wait':105 'web':12,40 'webkit':25","created_at":"2026-04-21T19:18:39.933951+00:00","updated_at":"2026-04-21T19:18:39.933951+00:00","problems":[{"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.","cause":"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.","error":"ERR_REQUIRE_ESM"},{"fix":"Run `npx playwright install chromium` to download and install the Chromium browser binaries. For all browsers, use `npx playwright install`.","cause":"The required browser binaries (e.g., Chromium) have not been installed or are corrupted for `playwright-core`.","error":"Error: Browser type 'chromium' is not found. Close all running browsers and try again."},{"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.","cause":"The installed Node.js version is below the minimum requirement for the Playwright Core package.","error":"Error: Node.js v16.x is not supported. Please upgrade to Node.js v18 or higher."},{"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 })`.","cause":"The specified element could not be found, was not visible, or was not actionable within the default timeout period.","error":"TimeoutError: locator.click: Timeout 30000ms exceeded."}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":"https://playwright.dev","github":"https://github.com/microsoft/playwright","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/playwright-core","openapi_spec":null,"status_page":null,"smithery":null,"categories":["testing","http-networking","web-framework","devops","data"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-20","install_tag":null}}