If a Playwright mobile screenshot is larger in pixels than the configured viewport, set scale: 'css' on page.screenshot(). Its documented default is 'device', which captures at device-pixel resolution; a high-DPI emulation can therefore produce an image wider or taller than the CSS viewport. Then check the device preset, viewport overrides and whether the capture is full-page.
Why a mobile screenshot can be bigger than its viewport
A viewport is measured in CSS pixels, while an image file has pixel dimensions. Those numbers need not match: page.screenshot() defaults to scale: 'device', so output pixels follow device-pixel resolution. On a high-DPI emulated device, the image may be larger than the CSS viewport—sometimes by a clean multiple, though there is no universal multiplier. Use Playwright’s screenshot API reference for the documented scale behavior.
For one output pixel per CSS pixel, set scale: 'css'. Choose 'device' when the higher-resolution device-pixel image is what you need.
Diagnose the size in this order
- Compare file dimensions with the intended viewport. Inspect the image’s actual width and height, then compare them with the configured CSS viewport width and height. A clean multiple can point to device scaling, but does not prove it.
- Set scale explicitly for direct screenshots. If the required output dimensions should match CSS pixels, pass
scale: 'css'topage.screenshot(). - Check device and viewport configuration. Presets include a bundle of emulated properties; confirm the selected preset and any project or context overrides.
- Check capture scope. A viewport screenshot reflects the visible viewport. With
fullPage: true, Playwright captures the full scrollable page, so the image can be much taller than the viewport by design. - Identify the screenshot API. The direct screenshot and screenshot assertion APIs document different scale defaults. Specify scale where the API supports it and dimensions must be predictable.
- If dimensions match but pixels still differ, stabilize the environment. Browser, operating system, settings, hardware, power source and headless mode can affect rendering. Compare in an environment matching the baseline.
Set the scale on a direct screenshot
For a viewport-sized image in CSS pixels:
await page.screenshot({ path: 'mobile.png', scale: 'css' });
For device-pixel resolution, request it explicitly instead:
#1 Best Overall
- 【Strong Adsorption】The inspiration of the silicone phone suction case comes from the adhesive force of the octopus. Each suction cup phone mount is 3.15 inches long and 2.17 inches wide, with 24 independent suction cups providing a stronger and more stable suction force, so you don't have to worry about your phone falling during use.
- 【Back of Phone Suction Grip】Remove the adhesive film on the phone suction cup and stick it on the phone case. You can then fix the phone on any smooth surface, which is very convenient. (The phone suction cup cannot be removed and reused after being attached to the phone case. It is recommended to attach it to a regular phone case, not a valuable one.)
- 【Widely Used】Our non-slip silicone phone sticky grip mount attaches to almost any flat phone case and make it compatible with common mobile phones such as iPhone and Android.You can shoot, watch videos or video calls in the kitchen, gym, dance studio, bathroom and other places.
- 【Capture the Wonderful Picture】Whether you are a TikTok creator or just like to share videos and photos, this phone suction cup can help you hands-free capture wonderful videos and photos for sharing with friends.
- 【Note】You can fix the phone suction cup on a smooth surface such as a mirror or glass. If necessary, wipe the suction cup with a damp cloth to obtain stronger suction. Before releasing your hand, make sure the phone is firmly fixed. (Not applicable to rough walls, wooden surfaces, and other uneven surfaces)
await page.screenshot({ path: 'mobile.png', scale: 'device' });
The first setting controls pixel density; it does not change the page’s CSS viewport. If the file is still too tall, inspect fullPage and the viewport configuration separately.
Check mobile presets and viewport overrides
Playwright device presets can set viewport, screen size, user agent and touch behavior. When spreading a preset and setting a custom viewport, put the override after the spread so it takes precedence. This example uses an illustrative preset and viewport; verify the device name and target dimensions against the Playwright version and device you intend to emulate.
Rank #2
- SUPERIOR COMFORT — Unlike traditional circular ear buds, the design of EarPods is defined by the geometry of the ear. Which makes them more comfortable for more people than any other ear bud–style headphones.
- HIGH-QUALITY AUDIO — The speakers inside EarPods have been engineered to maximize sound output and minimize sound loss, which means you get high-quality audio.
- BUILT-IN REMOTE — EarPods with USB-C plug also include a built-in remote that lets you adjust the volume, control the playback of music and video, and answer or end calls with a pinch of the cord.
- COMPATIBILITY — Works with all devices that have a USB-C port.
- INTEGRATED MICROPHONE — A built-in microphone precisely captures your voice while you’re on the phone, taking a FaceTime call, or summoning Siri — so you’re always heard loud and clear.
import { defineConfig, devices } from '@playwright/test';
export default defineConfig({
projects: [{
name: 'mobile-chromium',
use: {
...devices['iPhone 13'],
viewport: { width: 390, height: 844 },
},
}],
});
See Playwright’s device emulation documentation for preset configuration. If you set the viewport at runtime with page.setViewportSize(), Playwright resizes the page and resets screen. Set it before navigation where practical: a site may not expect a phone’s size to change mid-session. The API reference documents the method and behavior.
Choose viewport capture or full-page capture
Leave fullPage unset or set it to false when the artifact should have the visible viewport’s height. Use fullPage: true when the whole scrollable document is the intended result; a tall image is then expected. Full-page mode changes capture height, while scale determines the relationship between CSS and output pixels. See Playwright’s screenshot guide.
Rank #3
- Secure Hold: Our PopSockets adhesive phone grip gives your cell phone a secure, comfortable hold in hand to help prevent drops while texting, taking photos, or scrolling on the go. Designed to stick firmly to most phone cases and devices.
- Hands-Free Made Easy: Easily turn your PopSocket into a phone stand to prop up your phone anywhere, perfect for watching videos, video calls, or following recipes. A must-have phone holder that keeps your device secure and ready for anything.
- Compatibility: Works with all phones, tablets, and Kindles. Sticks best to smooth, hard plastic cases and may not adhere to silicone or textured cases. Easily swap your PopTop to change up your style.
- Black PopSockets: Simple, refined, and endlessly versatile. A timeless essential for any phone.
- Travel Must-Have for People On the Go: A must-have travel accessory for flights, flying, airports, air travel, airplanes, planes, international trips, cruises, and long travel days. Key gadget for your airport haul, travel accessories and must-haves.
Check screenshot assertions separately
page.screenshot() documents device as its scale default, while expect(page).toHaveScreenshot() documents css. If a test saves a direct screenshot and also compares an assertion screenshot, do not assume both APIs produce the same dimensions by default. Set the desired scale explicitly in the applicable options and consult the screenshot assertion API reference.
Troubleshoot common wrong-size results
| Symptom | Likely cause | What to check |
|---|---|---|
| Image is wider and taller than the CSS viewport by a consistent factor | page.screenshot() is using device-pixel scale. |
Set scale: 'css' if CSS-pixel dimensions are required; verify the actual image dimensions. |
| Image has the expected width but is far too tall | Full-page capture includes the scrollable page. | Remove fullPage: true for a viewport-only capture. |
| Configured viewport is not taking effect | A preset or later override supplies a different value. | Review merged project/context settings; put the intended viewport after the device spread. |
| Layout or screenshot changes after resizing | setViewportSize() ran after navigation, or screen-dependent behavior changed. |
Set the viewport before navigation when practical; remember that resizing resets screen. |
| Dimensions match, but visual comparison fails | Rendering differs across browser, OS, settings or execution environment. | Use the same browser, operating system and headless or headed mode as the baseline. |
Or skip the browser setup
If your task is to capture a URL rather than test Playwright’s emulated mobile environment, ScreenshotNeo offers a one-call screenshot API. This example saves the returned image as WebP; see the ScreenshotNeo API documentation for request options.
Rank #4
- [360 ° Flexible Rotation Design] Comes with a rotatable lanyard ring that supports 360 ° free rotation, effectively solving the problem of twisted and tangled lanyards
- [Wide compatibility] The ultra-thin 0.02-inch design does not block the charging port at all, and both wired and wireless charging can be used directly without removing the pad. Compatible with most smartphones such as iPhone, compatible with various wristbands, lanyards, crossbody straps, and keychains
- [Durable and Portable Material] Premium rust-resistant stainless steel material with good flexibility, which not only avoids scratching the phone case, but also has excellent anti rust and anti fading performance
- [Multi scenario Practical] Paired with a lanyard or wristband, hands-free use can be achieved. The phone is within reach and not easily dropped, ideal for daily commuting and outdoor activities. Suitable for full coverage phone cases, does not support half coverage phone cases
- [Quality Service] If you find any damage or other issues with the product upon receipt, please contact us immediately. We will handle it quickly
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
- It accepts cookie and consent banners before capture and removes more than 60 known consent platforms, newsletter popups and chat widgets; each step can be turned off.
- Bot checks or CAPTCHAs, blank pages, timeouts, failed loads and cache hits are not billed. Responses identify the page verdict and billing status in headers.
- An MCP server provides
take_screenshot,get_page_infoandcapture_pdffor Claude, Cursor and other MCP clients. - The Free plan includes 1,000 screenshots a month without a card; paid plans start at $5 for 3,000 shots.
Sign up for ScreenshotNeo’s free plan to start with 1,000 screenshots a month and no card.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Version and rendering notes
Playwright documentation is rolling; the references cited here were accessed on October 3, 2026. Confirm defaults and device registry names against the documentation for the Playwright version installed in your project. Browser, operating system, settings, hardware, power source and headless mode may all affect rendered pixels, so matching dimensions alone does not guarantee identical images.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Fix the driver behind crashes, sound loss and screen glitches3Clear out junk files and repair common Windows errorsBest Value
- 【PKYAA Double Sided Silicone Suction Phone Case Mount】PKYAA With Double Sided 40 Strong and Reliable individual suction cups, PKYAA provides a thicken and upgraded universal silicon suction mount for your phone.
- 【Friendly to Content Creators】If you are a content creator or an online influencer, you can create videos anywhere with this suction mount completely hands free with this silicone cell phone mount for cases.
- 【HANDS-FREE & Adhere to Mirrors】This Double Sided silicone suction phone case mount allows you to stick your phone to the mirror easily. No longer holding your phone in one hand to watch video tutorials while making up.
- 【Strong Grip on the Smooth Surface】You can easily hang your phone anywhere with a smooth surface. All you do is you clean off your phone and smooth surface. It is STURDY and it not only sticks to mirrors, it also sticks to windows, it sticks to refrigerators, tiles and other clean, flat surfaces.
- 【Press Down Firmly Every 30 Minutes】Use your palm or fingers to press the phone down firmly and check it's secure before letting go. Apply even pressure for a few seconds to allow the suction cup to adhere properly. To maintain the grip and prevent accidental falls, it's a good practice to periodically reapply pressure to the suction cup.
Frequently Asked Questions
Does setting scale: 'css' change the emulated mobile viewport?
No. It changes output image scaling, not the viewport configuration.
Why do two Playwright screenshot methods produce different dimensions by default?
The documented default for page.screenshot() is device, while toHaveScreenshot() documents css. Set the intended scale explicitly where dimensions matter.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




