Getting Started with the Microsoft Playwright Framework

Explore Microsoft Playwright, a versatile cross-browser test automation tool supporting multiple languages.

Playwright is one of the newest but fastest-growing cross-browser test automation frameworks. Built by the same team that built Puppeteer, Playwright is also a CDP-based framework. As opposed to Google’s Puppeteer, Playwright supports multiple languages and most leading browsers. With Playwright, we can script in JavaScript, TypeScript, Python, Java, and .NET and execute across most leading browsers, including Chrome, Firefox, Edge, and WebKit Safari. The Playwright framework can be executed in headed or headless mode and can also support mobile viewport emulation with various user agents, as opposed to Cypress, for example.

From an architecture perspective, Playwright uses the CDP to interact with the browsers, drive actions such as browsers’ pages’ inputs, scan for security, monitor network processes, and much more.

Getting started

Let’s start by creating a basic JavaScript test file, saving it with the *.spec.js extension, and placing it in the tests folder.

To run the test with the browser in a headed mode, we can run the following command:

Get hands-on with 1400+ tech skills courses.