Glossary term

Playwright

Playwright is an open-source automation framework by Microsoft that controls Chromium, Firefox, and WebKit browsers — used for testing, screenshots, and web automation across all major browser engines.

What Playwright can do

Playwright provides a unified API for automating browsers across all three major rendering engines: Chromium (powering Chrome and Edge), Firefox (Gecko), and WebKit (powering Safari). This cross-browser support is its defining feature — a single script can run against all three engines without modification.

Key capabilities include:

  • Cross-browser automation — write one script and run it against Chromium, Firefox, and WebKit. The Playwright CLI installs and manages the required browser binaries.
  • Screenshot capture — save pages as PNG or JPEG, capture the full page or a specific element, and set viewport dimensions and device emulation.
  • PDF generation — export rendered pages to PDF with full control over page size, margins, and scale.
  • Network interception — monitor, mock, or modify network requests for testing and data capture.
  • Browser contexts — create isolated browser sessions (like incognito windows) that share no cookies, storage, or state. Useful for capturing pages as different user types without restarting the browser.
  • Multi-language support — official bindings for JavaScript/TypeScript, Python, Java, and .NET.

Playwright's auto-waiting mechanism is particularly valuable. Unlike libraries that require explicit wait calls, Playwright automatically waits for elements to be attached to the DOM, visible, and stable before interacting with them. This makes scripts more reliable and reduces the "flaky test" problem.

Playwright for screenshots

Playwright's page.screenshot() method offers precise control over capture output. You can capture the visible viewport, the full scrollable page, or a specific DOM element by passing a locator.

Device emulation lets you simulate specific devices — setting viewport dimensions, device scale factor, and user agent in a single call. Playwright includes a built-in device registry with presets for popular phones and tablets, making it straightforward to capture how a page looks on an iPhone, Pixel, or iPad.

For pages with lazy-loaded content, Playwright's auto-scrolling behavior and wait conditions help ensure all images and dynamic content are loaded before capture. You can inject CSS to hide cookie banners, remove chat widgets, or adjust styling before taking the screenshot.

Because Playwright supports WebKit, it can expose rendering differences that a Chromium-only run would miss. Its patched WebKit build is not Safari itself, and operating-system details such as media codecs can still differ. Run WebKit on macOS when you need the closest available Safari comparison.

For a Shotomatic-adjacent workflow, Playwright becomes valuable when the same page needs to be captured repeatedly across browsers, routes, or authentication states. It turns screenshot production into an explicit recipe instead of a manual browser session, which is why it shows up so often in monitoring and QA pipelines.

Playwright vs Puppeteer

Both libraries are excellent for headless browser automation, but they differ in scope and philosophy.

Browser coverage — Playwright supports Chromium, Firefox, and WebKit through one API. Current Puppeteer releases support Chrome for Testing and stable Firefox, but not WebKit. Choose Playwright when WebKit coverage is required.

Auto-waiting — Playwright waits for elements to be ready before interacting. Puppeteer requires more explicit wait calls (waitForSelector, waitForNetworkIdle), which means more code and more potential for timing issues.

Browser contexts — Playwright's browser contexts allow multiple isolated sessions within a single browser instance, reducing resource usage. Puppeteer uses incognito browser contexts but the API is less developed.

API maturity — Puppeteer has been available since 2017 and has a larger ecosystem of community resources. Playwright launched in 2020 and has been growing rapidly, with more frequent releases and a broader feature set.

For screenshot-focused workflows, the choice often comes down to browser requirements. Chrome and Firefox capture work with either tool. Use Playwright when the comparison must also include WebKit.

Common mistakes

  • Not installing browser binaries. After installing the Playwright package, you must run the install command to download browser binaries. Without this step, scripts will fail with a "browser not found" error.
  • Ignoring auto-wait limits. While auto-waiting reduces flakiness, it has a default timeout. If a page is slow to load, actions may time out before content is ready. Adjust timeout values for content-heavy pages.
  • Capturing before lazy content loads. Even with auto-waiting, Playwright does not automatically scroll through the page. For full-page screenshots of lazy-loaded pages, add a scroll step before capture.
  • Using the wrong browser for the use case. Running all captures against Chromium is faster but misses rendering differences in Firefox and WebKit. Use cross-browser capture when the visual output must match what users see in different browsers.
  • Not closing browser contexts. Failing to close browser contexts after capture leads to memory leaks in long-running scripts. Always close contexts and browser instances when finished.

Common questions

Is Playwright free?

Yes. Playwright is open source under the Apache 2.0 license, maintained by Microsoft. It can be installed via npm, pip, or NuGet at no cost.

Which browsers does Playwright support?

Playwright supports its own Chromium, Firefox, and WebKit builds. It can also run installed Google Chrome and Microsoft Edge channels. Use the Playwright CLI to install and manage the matching browser binaries.

Can Playwright capture screenshots in Safari?

Playwright runs a patched WebKit build, not the branded Safari browser. You can run WebKit on Linux and Windows, but Playwright recommends macOS when you need the closest available result to Safari for platform-dependent behavior.

What programming languages does Playwright support?

Playwright has official libraries for JavaScript/TypeScript (Node.js), Python, Java, and .NET. The JavaScript version is the most widely used and typically receives new features first.

How does Playwright handle dynamic content?

Playwright includes built-in auto-waiting — it automatically waits for elements to be visible, stable, and actionable before interacting with them. This reduces flaky scripts and makes it easier to capture pages with animations or lazy-loaded content.

Sources

Related resources

What Is Playwright? | Glossary | Shotomatic