Skip to content

Playwright vs Puppeteer

Shubham Thakur edited this page Jun 24, 2023 · 22 revisions

Playwright vs. Puppeteer

⚑ Note: playwright-extra is now available.


  • Playwright and Puppeteer are modern browser automation libraries to control real browsers with code
  • Both are Node.js based and use the Chrome DevTools Protocol (CDP) behind the scenes
  • They share the same roots and their APIs (e.g. page.goto()) are often the same or very similar

TL;DR - Which one should I use?

Switching them out later is relatively easy as their APIs are so similar, choose based on your current needs.

  • Choose Playwright
    • If you need to use browsers other than Chrome/Chromium right now.
  • Choose Puppeteer
    • If you rely on being able to use more pre-made plugins right now.

πŸ‘¨β€πŸ« A little bit of history...

Puppeteer & Playwright

  • Puppeteer started as official Google project in 2017 and quickly gained popularity
    • It's considered to be the first "modern" browser automation tool, superseding projects like Selenium and PhantomJS
  • Playwright started in 2020 after Microsoft bought hired a few of the core Puppeteer maintainers
    • They started fresh with prior experience: TypeScript and multi-browser support from the get go
  • Both are actively maintained and push regular updates

Plugin Framework: puppeteer-extra, playwright-extra, automation-extra

  • We started the project in 2018 with puppeteer-extra, a modular plugin framework for Puppeteer
    • We introduced popular plugins like stealth and recaptcha
    • Plugins are based off puppeteer-extra-plugin
  • We rewrote the plugin framework in 2020 to introduce additional support for Playwright
    • A new automation-extra package now acts as a shared foundation for all drivers
    • playwright-extra & puppeteer-extra have transitioned to slim entry points for automation-extra
    • New plugins will be based off automation-extra-plugin, which supports both Playwright & Puppeteer events

Plugin Support

  • Playwright support in the plugin framework doesn't mean all existing plugins can be used with Playwright immediately
    • The existing puppeteer-extra plugins need to be ported to automation-extra-plugin and further optimized to be used with Firefox and Webkit
  • New plugins work with both playwright-extra as well as puppeteer-extra and usually all browsers
  • You can recognize new plugins by their package name: @extra/foobar as opposed to puppeteer-extra-plugin-foobar

βš– Differences

Browser Support

  • Playwright has first class support for Chromium, Firefox and Webkit browsers
    • They accomplish this by maintaining a set of browser patches and shipping custom binaries
    • They introduced a unified wire protocol which internally translates to CDP, Juggler, WDP
  • Puppeteer has been heavily Chromium focussed and only recently added Firefox support to their core
    • Instead of maintaining patches they work with the browser vendors to improve their CDP functionality
    • Their Firefox support is currently no match for Playwright, even basic features are missing
  • Both ship with their own Chromium version, a regular Chrome browser (ideally dev/canary versions) can be used as well

Conceptual Differences

  • The most noticeable difference between the two (in terms of API usage) is that Playwright leans heavily on the concept of browser contexts

πŸ“š Further Reading