I wanted a place to capture a list of highlights that make Playwright awesome. Here it is, in no particular order:
- Uses the concept of browser contexts (equivalent to a brand new browser profile) to run tests in isolation with zero overhead (super fast!).
- VS Code extension has features to run tests with a single click, debug step by step, explore selectors, and record new tests (codegen).
- HTML report to view execution results in your browser. Includes visual diffs, and artifacts like traces, error logs, video recordings, and screenshots. The entire report is a self-contained page that can be easily hosted anywhere.
- Fastest test execution time in Checkly’s benchmarks versus Cypress, Selenium, and Puppeteer.
- Built-in toMatchScreenshot() to support visual regression testing, with recent improvements such as disabling animations and masking elements.
- Parallel test execution is supported locally, or remotely for grids such as Selenium Grid. In addition, you can shard tests between machines to run different tests in parallel e.g. using a GitHub Action CI job matrix.
- Cross-browser compatibility for Chromium, Chrome, Microsoft Edge, Firefox, WebKit.
- Built and maintained by Microsoft ♥️ Ok, I’m probably being biased here 😄
- Tracing that helps with troubleshooting test runs in a post-mortem manner. This works great to repro failed CI tests.
- Re-use signed-in state so tests can start as a logged-in user, saving time.
- Emulation for mobile devices, user agents, locales & timezones, permissions, geolocation, and dark/light mode.
- Works well with the white-box testing approach to prioritize user-facing attributes like text, instead of CSS selectors that can change frequently.
- Support for API Testing, to do things in your e2e test like set up data or assert things like response code = 200.
- Stub and mock network requests with network interception.
- Actions have auto-waiting built-in, so you don’t need to rely on hard-coded sleep commands that can cause flakiness and slow down tests. Also has custom waits such as until an element is visible, or until a pop-up is loaded.
- Support for recording user actions as Playwright test code aka Test Generator, that can be run via CLI or the record button in VS Code.
- Supports device-specific events like hovering with mouse, tapping on mobile, and keyboard shortcuts.
- Upload and download files supported out of the box.
- The magic of Locators eliminates flakiness caused by dynamic controls.
- Playwright Test uses the same Expect assertion library as Jest which will be familiar to many JS devs.
- Supports tagging of tests so you can run groups of related tests e.g. `@priority=high`, `@duration=short`.
- Provides docker images that have dependencies and browsers baked in. This makes CI configuration simple and fast.
Did I miss anything? Post your thoughts in the comments…
3 thoughts on “25 reasons to choose Playwright as your next web testing framework”
this was very helpful. Thank you
Really helpful. Thanks for sharing. You have stoked my interest on Playwright 🙂
Other advantages that I have seen:
* Playwright is about 30% faster running the same tests than Selenium due to its ability to create test contexts in 100ms.
* Because Microsoft includes all three drivers for Chromium, Firefox, and Webkit, it makes it easier to maintain.
* The included browser versions are ahead of production making it possible to determine compatibility early.