


Posted in Software & Development
February 27, 2024
TECHNOLOGY INSIGHT
Playwright - Technical Review
Tyler Marshall explores the power of Playwright: Microsoft's cutting-edge tool for browser automation. Discover how Playwright is revolutionizing web testing, from seamless cross-browser support to unmatched efficiency in development cycles.
Introduction to Playwright
Playwright.dev is an open-source Node.js library developed by Microsoft. It provides a high-level API for automating Chromium, Firefox, and WebKit browsers.
Playwright is primarily used for browser automation for testing web applications and supporting cross-browser testing with a single API. Its key use cases include end-to-end testing, generating screenshots, and automating interactions with web applications.
Playwright supports languages such as JavaScript, Python, C#, and Java. The original use case, and the one this article focuses on, is for JavaScript.
Performance Benefits of Playwright
Development Cycle Improvements

1. Iteration speed
Playwright uses pretty straightforward syntax, which should feel very familiar to someone used to writing similar tests in Cypress or other frameworks.
At its core, Playwright has Actions and Assertions.
- Actions are things such as navigation (going to pages) and interactions (clicking buttons), and they have a variety of helper functions for executing basic actions to mimic a real user.
- Assertions are pretty standard across testing frameworks, and it is no exception for Playwright. It uses expect syntax and has a list of useful assertions the developer may need to include.
Each test is run in isolation, and Playwright provides hooks such as the popular test.describe for grouping tests, as well as beforeEach and others.
Overall, a developer experienced with some level of testing framework should be able to pick up the technology fairly quickly.
2. Build and Deployment
Unsurprisingly, Playwright provides the ability to run tests in a CI/CD environment. While they seem to have a pull towards GitHub Actions, they do support tests if your CI agent can run a browser.
Playwright provides a list of their own Docker image or conveniently provides required dependencies using a CLI command.
They recommend only having 1 running worker if you are not on a self-hosted CI system. If you have a powerful enough setup, you can run tests in parallel and even share the tests across multiple CI jobs.
There is a provided Dockerfile for GitLab CI with instructions for running tests in parallel and/or sharding.
3. Runtime Efficiency
- Speed Benchmarks: Playwright demonstrates impressive speed, often outperforming similar tools like Selenium.
- Resource Consumption: Efficient in terms of memory and CPU usage, especially in headless mode.
Playwright’s Differentiating Features
Playwright calls out the following features:
- Cross-browser support: Supports all modern browsers.
- Cross-platform support: Test anywhere (Windows, Linux, macOS, CI, headless, headed).
- Cross-[programming] language: The API is available for TS, JS, Python, .NET, and Java.
- Test Mobile Web: Emulate real devices and test on any browser by updating configuration parameters.
- Auto-wait: Waits for elements to be ready before actions begin, removing the need for artificial timeouts.
- Web-first assertions: Assertions were created for a dynamic web environment, meaning checks will be retried automatically.
- Tracing: Specify a test retry strategy and capture execution traces, videos, and screenshots to eliminate flaky tests.
- Log in once: Saves authentication state to reuse it in all tests.
- Browser contexts: A new browser context for each test (akin to a brand new browser profile).
- Codegen: Generate tests automatically by recording actions.
The Playwright Ecosystem: Support, Community, Tooling and More.
Built-in Support
Offers built-in features like network interception, emulation of different devices, and support for multi-page scenarios. Their documentation is also really well-written and appears to cover a wide array of use cases. Most documentation has examples the developer can reference.
Community Contributions
Playwright has community support with an array of plugins and integrations. Their GitHub is active, and everything is open-sourced, which makes transparency a priority. They seem to have a tendency to support their ambassadors, which is a nice community feature.
Community, Support, and Longevity
Strong community and backing by Microsoft. Continuous updates and a clear roadmap suggest a promising future.
Development Tooling
Playwright has tools for debugging, including tracing and screenshot/video capture. Playwright supports GitLab CI and should fit in with the existing pipeline if you wish to do that.
Integration and Compatibility
It is a new testing framework, and with that, new processes and procedures would have to be followed. A re-write of an existing test suite would likely be the step if it was to be integrated into an existing project.
As with all testing frameworks, complex projects will end up with some complex tests. I don’t think it is specific to Playwright, but the lack of experience with the tool may be an efficiency problem.
Ease of Adoption
- Learning curve — The documentation provided is pretty straightforward and similar to other testing frameworks. I wouldn’t expect simple tests to take any extra overhead.
- Developer Experience — The syntax is pretty standard. The documentation is amazing, and the examples provided are extremely helpful. The UI tool is nice to look at and easy to use.
Recommendations & Next Steps
After reviewing Playwright as a testing framework, here are my suggested next steps
Adopt Immediately
- I would consider adopting this technology on the next project I start. It doesn’t appear to have any big flaws, and given the growing community and backing by Microsoft, it could be a great asset in the future.
- Action Points: On a case-by-case basis, but for the next project to get kicked off, I would have no issues using Playwright.
Or,
Consider Further Review
- Because the existing testing frameworks we use are widely understood by most internal developers, it may not be worth the effort to move existing tests over to Playwright. I think it would be valuable to have Playwright running in one or two production projects, and if the development team finds the benefits far outweigh the cons, I would advocate for a change.
- Action Points: Review community adoption. When challenges arise within Cypress or the existing framework, cross-reference with Playwright to consider alternatives.
Ready to talk about the future of web development?
Want to know more about the world-class development tools we use at Acro Commerce?
Fill in the form below, and one of our subject matter experts will reach out.