Playwright
What Playwright is, how it captures cross-browser screenshots, and how it compares to Puppeteer for automation.
Playwright is an open-source browser automation library maintained by Microsoft. It drives Chromium, Firefox and WebKit through one API and has official bindings for JavaScript and TypeScript, Python, Java and .NET. A script opens pages, clicks, types, waits for network activity and reads the DOM, usually in a headless browser with no visible window.
Playwright ships with its own test runner, Playwright Test, which adds parallel test execution, retries, tracing and screenshot assertions. Many teams use it for end-to-end tests and for generating screenshots as part of a build or deploy pipeline.
What Playwright can do
- Open a page in Chromium, Firefox or WebKit with the same script.
- Emulate a device: viewport size, device scale factor, touch, locale, time zone and color scheme.
- Fill forms, click elements and wait for selectors, network requests or page load states.
- Intercept or mock network requests.
- Record traces, videos and screenshots of each test run.
Playwright for screenshots
page.screenshot() saves the current viewport as PNG or JPEG. The fullPage option captures the whole scrollable page, clip captures a rectangle, and locator.screenshot() captures a single element. The deviceScaleFactor of the browser context decides whether the output is 1x or 2x resolution.
In Playwright Test, toHaveScreenshot() compares a new image with a stored baseline and fails the test when the pixel difference exceeds a threshold. This is a common base for visual regression testing.
Playwright vs Puppeteer
Both libraries automate browsers from code and both capture screenshots and PDFs. Playwright supports Chromium, Firefox and WebKit and has bindings for four language ecosystems. Puppeteer is a Node.js library focused on Chrome, with Firefox support added later. Playwright includes a full test runner; Puppeteer is usually combined with a separate runner such as Jest. The choice often comes down to language, browser coverage and what the team already uses.
Common mistakes
- Capturing before web fonts, images or lazy-loaded content finish loading.
- Leaving cookie banners or chat widgets in the frame.
- Comparing baselines taken on a different operating system, where font rendering differs.
- Forgetting that the default viewport is small, not a typical desktop width.
Taking the same screenshots again and again?
Temposhot Website Capture captures a list of URLs at Desktop 1920×1080, Tablet 768×1024 or Mobile 390×844 without writing a script. See website screenshot automation.
Common questions
Is Playwright free?
Yes. Playwright is open source under the Apache 2.0 license.
Can Playwright capture a full web page?
Yes. Pass fullPage: true to page.screenshot(). Pages with lazy loading may need to be scrolled first so all images load.
Does Playwright need a visible browser?
No. It runs headless by default and can also run with a visible window for debugging.
Sources
Related resources
- Website Capture quick start: capture a URL list without code.
- Website Capture options: device, area, wait and format settings.
- Compare images: check two screenshots for differences in the browser.
Taking the same screenshots again and again?
Temposhot captures a screen, window or area on a timer and exports the set as a PDF, images, ZIP or MP4. The free browser tools fix single images.
Related resources
Related terms
- PuppeteerWhat Puppeteer is, how it captures screenshots, and how it compares to Playwright for browser automation.
- Headless BrowserWhat a headless browser is, how it's used for automated screenshots, and common pitfalls.
- Visual Regression TestingWhat visual regression testing is, how screenshot comparison catches UI bugs, and common pitfalls.
- Screenshot APIWhat a screenshot API is, how it works, and when to use one for programmatic capture.