playwright vs puppeteer-core vs puppeteer
Web Automation Libraries Comparison
1 Year
playwrightpuppeteer-corepuppeteerSimilar Packages:
What's Web Automation Libraries?

Web automation libraries are tools designed to facilitate automated interactions with web browsers. They allow developers to simulate user actions, perform testing, and scrape web content programmatically. These libraries can be particularly useful for end-to-end testing, web scraping, and automating repetitive tasks in web applications. Each library has its unique strengths, making them suitable for different use cases in web development and testing.

Package Weekly Downloads Trend
Github Stars Ranking
Stat Detail
Package
Downloads
Stars
Size
Issues
Publish
License
playwright12,727,80369,7843.18 MB750a month agoApache-2.0
puppeteer-core7,965,70089,8588.09 MB2657 days agoApache-2.0
puppeteer4,555,97089,858359 kB2657 days agoApache-2.0
Feature Comparison: playwright vs puppeteer-core vs puppeteer

Browser Support

  • playwright:

    Playwright supports multiple browsers including Chromium, Firefox, and WebKit, allowing for comprehensive cross-browser testing. This means you can write tests once and run them across different browser engines, ensuring consistent behavior and performance across platforms.

  • puppeteer-core:

    puppeteer-core does not include a bundled browser, allowing you to connect to an existing installation of Chromium. This gives you the flexibility to use a specific version of Chromium that may be required for your testing or automation tasks.

  • puppeteer:

    Puppeteer is primarily designed for Chrome and Chromium, which makes it less versatile in terms of browser support. It excels in automating tasks specifically within the Chrome ecosystem, providing deep integration with Chrome's features and capabilities.

API Complexity

  • playwright:

    Playwright offers a rich and modern API that includes advanced features like auto-waiting for elements, which simplifies test writing and reduces flakiness. Its API is designed to handle asynchronous operations more intuitively, making it easier for developers to write reliable tests.

  • puppeteer-core:

    puppeteer-core shares the same API as Puppeteer but is stripped of the bundled browser. This means you get the same simplicity and ease of use, but you need to manage the browser installation separately.

  • puppeteer:

    Puppeteer provides a simpler API that is easy to understand and use, especially for developers familiar with Chrome. While it may lack some advanced features compared to Playwright, it is straightforward for basic automation tasks and web scraping.

Performance

  • playwright:

    Playwright is optimized for speed and performance, with features like parallel execution of tests and efficient handling of multiple contexts. This allows for faster test execution and better resource management, especially in CI/CD environments.

  • puppeteer-core:

    Since puppeteer-core does not include a bundled browser, its performance is dependent on the external Chromium instance you are using. This can lead to variations in performance based on the browser version and configuration.

  • puppeteer:

    Puppeteer is also performant, particularly for tasks focused on Chrome. However, it may not match Playwright's capabilities in terms of parallel execution and handling multiple browser contexts simultaneously.

Community and Ecosystem

  • playwright:

    Playwright has a rapidly growing community and is backed by Microsoft, which ensures regular updates and a robust ecosystem. It integrates well with various testing frameworks and tools, making it a strong choice for modern web applications.

  • puppeteer-core:

    puppeteer-core benefits from the same community and ecosystem as Puppeteer, but it may have fewer resources specifically tailored to it since it is a more specialized version.

  • puppeteer:

    Puppeteer has a well-established community and is widely used in the industry, particularly for Chrome automation. It has a rich set of resources, tutorials, and third-party tools that enhance its usability and integration with other libraries.

Use Cases

  • playwright:

    Playwright is ideal for comprehensive end-to-end testing across multiple browsers, web scraping, and automating complex user interactions. Its versatility makes it suitable for a wide range of applications, from testing web apps to automating workflows.

  • puppeteer-core:

    puppeteer-core is perfect for scenarios where you want to use Puppeteer's API without bundling a browser. It is useful in CI/CD pipelines or environments where you manage your own browser installations, providing flexibility in how you deploy your automation tasks.

  • puppeteer:

    Puppeteer is best suited for tasks that specifically require Chrome automation, such as generating PDFs, taking screenshots, and scraping data from web pages. It is particularly effective for projects that target Chrome-centric environments.

How to Choose: playwright vs puppeteer-core vs puppeteer
  • playwright:

    Choose Playwright if you need a modern, versatile tool that supports multiple browsers (Chromium, Firefox, and WebKit) and offers advanced features like auto-waiting, network interception, and cross-browser testing. It is particularly beneficial for projects that require high reliability and speed in testing across different environments.

  • puppeteer-core:

    Opt for puppeteer-core when you want to use Puppeteer without bundling a Chromium instance. This is useful for environments where you already have a compatible version of Chromium installed, allowing for more control over the browser version and reducing the package size. It is ideal for CI/CD pipelines or server environments where you manage browser installations separately.

  • puppeteer:

    Select Puppeteer if your primary focus is on automating Chrome or Chromium-based browsers. Puppeteer provides a rich API for controlling headless Chrome, making it ideal for tasks like web scraping, generating PDFs, and taking screenshots. It is well-suited for projects that specifically target the Chrome ecosystem and need a straightforward setup.

README for playwright

🎭 Playwright

npm version Chromium version Firefox version WebKit version Join Discord

Documentation | API reference

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API. Playwright is built to enable cross-browser web automation that is ever-green, capable, reliable and fast.

| | Linux | macOS | Windows | | :--- | :---: | :---: | :---: | | Chromium 133.0.6943.16 | :white_check_mark: | :white_check_mark: | :white_check_mark: | | WebKit 18.2 | :white_check_mark: | :white_check_mark: | :white_check_mark: | | Firefox 134.0 | :white_check_mark: | :white_check_mark: | :white_check_mark: |

Headless execution is supported for all browsers on all platforms. Check out system requirements for details.

Looking for Playwright for Python, .NET, or Java?

Installation

Playwright has its own test runner for end-to-end tests, we call it Playwright Test.

Using init command

The easiest way to get started with Playwright Test is to run the init command.

# Run from your project's root directory
npm init playwright@latest
# Or create a new project
npm init playwright@latest new-project

This will create a configuration file, optionally add examples, a GitHub Action workflow and a first test example.spec.ts. You can now jump directly to writing assertions section.

Manually

Add dependency and install browsers.

npm i -D @playwright/test
# install supported browsers
npx playwright install

You can optionally install only selected browsers, see install browsers for more details. Or you can install no browsers at all and use existing browser channels.

Capabilities

Resilient • No flaky tests

Auto-wait. Playwright waits for elements to be actionable prior to performing actions. It also has a rich set of introspection events. The combination of the two eliminates the need for artificial timeouts - a primary cause of flaky tests.

Web-first assertions. Playwright assertions are created specifically for the dynamic web. Checks are automatically retried until the necessary conditions are met.

Tracing. Configure test retry strategy, capture execution trace, videos and screenshots to eliminate flakes.

No trade-offs • No limits

Browsers run web content belonging to different origins in different processes. Playwright is aligned with the architecture of the modern browsers and runs tests out-of-process. This makes Playwright free of the typical in-process test runner limitations.

Multiple everything. Test scenarios that span multiple tabs, multiple origins and multiple users. Create scenarios with different contexts for different users and run them against your server, all in one test.

Trusted events. Hover elements, interact with dynamic controls and produce trusted events. Playwright uses real browser input pipeline indistinguishable from the real user.

Test frames, pierce Shadow DOM. Playwright selectors pierce shadow DOM and allow entering frames seamlessly.

Full isolation • Fast execution

Browser contexts. Playwright creates a browser context for each test. Browser context is equivalent to a brand new browser profile. This delivers full test isolation with zero overhead. Creating a new browser context only takes a handful of milliseconds.

Log in once. Save the authentication state of the context and reuse it in all the tests. This bypasses repetitive log-in operations in each test, yet delivers full isolation of independent tests.

Powerful Tooling

Codegen. Generate tests by recording your actions. Save them into any language.

Playwright inspector. Inspect page, generate selectors, step through the test execution, see click points and explore execution logs.

Trace Viewer. Capture all the information to investigate the test failure. Playwright trace contains test execution screencast, live DOM snapshots, action explorer, test source and many more.

Looking for Playwright for TypeScript, JavaScript, Python, .NET, or Java?

Examples

To learn how to run these Playwright Test examples, check out our getting started docs.

Page screenshot

This code snippet navigates to Playwright homepage and saves a screenshot.

import { test } from '@playwright/test';

test('Page Screenshot', async ({ page }) => {
  await page.goto('https://playwright.dev/');
  await page.screenshot({ path: `example.png` });
});

Mobile and geolocation

This snippet emulates Mobile Safari on a device at given geolocation, navigates to maps.google.com, performs the action and takes a screenshot.

import { test, devices } from '@playwright/test';

test.use({
  ...devices['iPhone 13 Pro'],
  locale: 'en-US',
  geolocation: { longitude: 12.492507, latitude: 41.889938 },
  permissions: ['geolocation'],
})

test('Mobile and geolocation', async ({ page }) => {
  await page.goto('https://maps.google.com');
  await page.getByText('Your location').click();
  await page.waitForRequest(/.*preview\/pwa/);
  await page.screenshot({ path: 'colosseum-iphone.png' });
});

Evaluate in browser context

This code snippet navigates to example.com, and executes a script in the page context.

import { test } from '@playwright/test';

test('Evaluate in browser context', async ({ page }) => {
  await page.goto('https://www.example.com/');
  const dimensions = await page.evaluate(() => {
    return {
      width: document.documentElement.clientWidth,
      height: document.documentElement.clientHeight,
      deviceScaleFactor: window.devicePixelRatio
    }
  });
  console.log(dimensions);
});

Intercept network requests

This code snippet sets up request routing for a page to log all network requests.

import { test } from '@playwright/test';

test('Intercept network requests', async ({ page }) => {
  // Log and continue all network requests
  await page.route('**', route => {
    console.log(route.request().url());
    route.continue();
  });
  await page.goto('http://todomvc.com');
});

Resources