{"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.","language":"javascript","status":"active","last_verified":"Tue Apr 21","install":{"commands":["npm install playwright-core"],"cli":null},"imports":["import { chromium } from 'playwright-core';","import type { Browser, Page } from 'playwright-core';","import { firefox, webkit } from 'playwright-core';"],"auth":{"required":false,"env_vars":[]},"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.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}