An Introduction to Playwright

Basic Notes

Mainly based on https://blog.logrocket.com/playwright-vs-puppeteer/ ; the following is a set of notes.

Since Chrome introduced support for headless browsers , web-automation frameworks have evolved rapidly, replacing complicated and tedious tools once maintained by individual developers, such as PhantomJS and Selenium.

Puppeteer is officially supported by Chrome and is based on the DevTools Protocol, making it more stable than PhantomJS, which is based on WebDriver.

Playwright was created by developers from the Puppeteer team. Compared with Puppeteer:

  1. The API is similar, so adoption costs are low.
  2. Some APIs are more ergonomic and make it easy to emulate different devices.
  3. It supports Firefox and WebKit, although compatibility is less complete (perhaps the Playwright and Puppeteer teams will build together someday…).

When choosing between Playwright, Puppeteer, Cypress, PhantomJS, and Selenium (which has many workarounds but is also flaky), consider:

  1. Cross-browser support. According to the referenced article, Playwright currently does best, but no one can guarantee Puppeteer and Cypress will always lag behind.
  2. Long-term support.
  3. The specific business context.

Choosing for a Project

For a new project, Playwright is recommended. See item 2 in Other References below for a detailed comparison.

Other References

  1. The reckless, infinite scope of web browsers — reflections on the modern browser ecosystem.
  2. Playwright VS Selenium VS Puppeteer VS Cypress — a broad, multidimensional Chinese comparison of popular web-automation frameworks.
  3. Puppeteer, Selenium, Playwright, Cypress – how to choose? — the article cited at the beginning of the Chinese post above.