

Posted in
February 27, 2024
TECHNOLOGY INSIGHT
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.
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.

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.
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.
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.
Playwright calls out the following features:
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.
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.
Strong community and backing by Microsoft. Continuous updates and a clear roadmap suggest a promising future.
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.
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.
After reviewing Playwright as a testing framework, here are my suggested next steps
Or,
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.