DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
Cupertino desk6 min

How to Capture a Mobile Website Screenshot with Playwright on an iPhone-Sized Viewport

Use Playwright’s iPhone-style device profile or an explicit viewport to capture a mobile website, with guidance on full-page screenshots, output scale, and visual-test reliability.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use a Playwright device profile such as iPhone 13 to emulate an iPhone-sized browser context, then call page.screenshot(). The result is a browser-emulated screenshot, not a photo or capture from physical iPhone hardware. If you need only particular dimensions, set an explicit viewport instead.

Use an iPhone device profile

This runnable Node.js example uses Playwright’s Chromium browser and the iPhone 13 profile documented in Playwright’s device emulation guide. Device profiles include browser parameters such as viewport, screen size, user agent, and touch capability. Confirm that the named profile exists in the device registry for the Playwright version installed in your project.

As an Amazon Associate I earn from qualifying purchases.

  1. Install Playwright if it is not already in the project: npm install -D playwright.

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  2. Save this as mobile-shot.mjs:

    import { chromium, devices } from 'playwright';
    
    const browser = await chromium.launch();
    try {
      const context = await browser.newContext({
        ...devices['iPhone 13'],
      });
      const page = await context.newPage();
      await page.goto('https://example.com', { waitUntil: 'load' });
      await page.screenshot({ path: 'mobile-page.png' });
    } finally {
      await browser.close();
    }
  3. Run it with node mobile-shot.mjs. Playwright writes mobile-page.png in the current directory. Replace the example URL with the page you want to capture.

    #1 Best Overall
    Apple iPhone 15 Pro, 128GB, Blue Titanium - Unlocked (Renewed)
    • 6.1inch Super Retina XDR display. ProMotion technology. Always-On display. Titanium with textured matte glass back. Action button
    • Dynamic Island. A magical way to interact with iPhone. A17 Pro chip with 6-core GPU
    • Pro camera system. 48MP Main | Ultra Wide| Telephoto. Super-high-resolution photos (24MP and 48MP). Next-generation portraits with Focus and Depth Control. Up to 10x optical zoom range
    • Emergency SOS via satellite. Crash Detection. Roadside Assistance via satellite
    • Up to 29 hours video playback. USB-C, Supports USB 3 for up to 20x faster transfers. Face ID

The default screenshot is the current viewport. The navigation waits for the page load event; sites that continue rendering content afterward may need an additional wait strategy, described below.

Choose a device profile or an exact viewport

Use a named profile when you want a coordinated set of emulated device settings, not just a width and height. Use an explicit viewport when exact dimensions are the only requirement. Playwright documents both context configuration and page-level viewport changes in its emulation guide.

Method Best suited to What it configures
Named device profile Emulating a device-style browser setup A bundle of settings, including viewport, screen size, user agent, and touch capability
Explicit viewport Controlling exact width and height Viewport dimensions; it does not by itself supply the other profile settings

To override a profile setting, put the explicit value after the profile spread; later object properties take precedence:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
const context = await browser.newContext({
  ...devices['iPhone 13'],
  viewport: { width: 390, height: 844 },
});

The dimensions above are an illustrative explicit viewport, not a claim that every iPhone has those dimensions. For viewport-only emulation, omit the device spread:

const context = await browser.newContext({
  viewport: { width: 390, height: 844 },
});

You can also change a page’s viewport after creating it:

Rank #2
Apple iPhone 15 Pro, 128GB, Black Titanium - Unlocked (Renewed)
  • 6.1inch Super Retina XDR display. ProMotion technology. Always-On display. Titanium with textured matte glass back. Action button
  • Dynamic Island. A magical way to interact with iPhone. A17 Pro chip with 6-core GPU
  • Pro camera system. 48MP Main | Ultra Wide| Telephoto. Super-high-resolution photos (24MP and 48MP). Next-generation portraits with Focus and Depth Control. Up to 10x optical zoom range
  • Emergency SOS via satellite. Crash Detection. Roadside Assistance via satellite
  • Up to 29 hours video playback. USB-C, Supports USB 3 for up to 20x faster transfers. Face ID
await page.setViewportSize({ width: 390, height: 844 });

That changes the viewport dimensions; it does not turn the context into a complete named device profile.

Capture the first screen or the whole page

page.screenshot() captures the visible viewport by default, which is usually the right choice for checking the initial mobile layout. Set fullPage: true to capture the full scrollable page, including content below the fold. The screenshot API documents these options and supported output formats in the page screenshot reference.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
await page.screenshot({
  path: 'mobile-page-full.png',
  fullPage: true,
  scale: 'css',
});

Full-page capture can produce a very tall image on long pages. Use viewport-only output when you need to review the first screen or keep the image to a predictable height.

Select image format and raster scale

Playwright supports PNG, JPEG, and WebP screenshots. The file extension can determine the output format; you can also specify type explicitly. Select the scale according to the image’s intended use:

Scale Output behavior Useful when
css One output pixel per CSS pixel You want compact output dimensions aligned with CSS layout dimensions
device Output uses device-pixel resolution and can be larger, especially for high-DPI settings You need the emulated device-pixel resolution for downstream use

For example, use a WebP filename and device scale for a viewport capture:

Rank #3
Apple iPhone 15 Pro, 256GB, Black Titanium - Unlocked (Renewed)
  • 6.1" LTPO Super Retina XDR OLED, 120Hz, HDR10, Dolby Vision, 1179x2556px, 1000 nits (typ), 2000 nits (HBM), 19.5:9 ratio, 3274mAh Battery
  • 256GB 8GB RAM, Apple A17 Pro (3 nm), Hexa-core (2x3.78 GHz + 4x2.11 GHz), Apple GPU (6-core graphics), iOS 17, upgradable to iOS 17.6.1, planned upgrade to iOS 18
  • Rear camera: 48MP, f/1.8 (wide) + 12MP, f/2.8 (telephoto) 3x optical zoom + 12MP, f/2.2 (ultrawide), Front Camera: 12MP, f/1.9 (wide)
  • 2G: 850/900/1800/1900, 3G: HSDPA 850/900/1700(AWS)/1900/2100, 4G LTE: 1/2/3/4/5/7/8/12/13/14/17/18/19/20/25/26/28/29/30/32/34/38/39/40/41/42/46/48/53/66/71, 5G: 1/2/3/5/7/8/12/14/20/25/26/28/29/30/38/40/41/48/53/66/70/71/77/78/79/258/260/261 SA/NSA/Sub6/mmWave - Dual eSIM
  • Unlocked for freedom to choose your carrier. Compatible with both GSM & CDMA networks. The phone is unlocked to work with all GSM Carriers & CDMA Carriers Including AT&T, T-Mobile, Verizon, Sprint., Etc.
await page.screenshot({
  path: 'mobile-page.webp',
  scale: 'device',
});

To set a format independently of the filename, specify it directly, for example type: 'jpeg'. These format and scale choices change the output image, not the fact that rendering is emulated. See the screenshot API options for the supported parameters.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use Playwright Test or codegen when they fit your workflow

Playwright Test projects

In Playwright Test, configure a project with a named device profile by spreading it into use:

import { defineConfig, devices } from '@playwright/test';

export default defineConfig({
  projects: [
    {
      name: 'iPhone 13 emulation',
      use: { ...devices['iPhone 13'] },
    },
  ],
});

Alternatively, set a project viewport when dimensions alone are what matters. The same ordering rule applies: place explicit overrides after the spread.

Code generator

To launch Playwright’s code generator with a named profile, run npx playwright codegen --device="iPhone 13" https://example.com. For an explicit viewport rather than a named device, use --viewport-size="800,600"; that option specifies dimensions and is not a substitute for a device profile. See the codegen guide.

Make captures more reliable

A page’s load event does not guarantee that every image, animation, API-driven component, or lazy-loaded section has finished rendering. Choose a wait that matches the page rather than relying on an arbitrary delay for every site:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Apple iPhone 15 Pro, 256GB, Blue Titanium - Unlocked (Renewed)
  • 6.1" LTPO Super Retina XDR OLED, 120Hz, HDR10, Dolby Vision, 1179x2556px, 1000 nits (typ), 2000 nits (HBM), 19.5:9 ratio, 3274mAh Battery
  • 256GB 8GB RAM, Apple A17 Pro (3 nm), Hexa-core (2x3.78 GHz + 4x2.11 GHz), Apple GPU (6-core graphics), iOS 17, upgradable to iOS 17.6.1, planned upgrade to iOS 18
  • Rear camera: 48MP, f/1.8 (wide) + 12MP, f/2.8 (telephoto) 3x optical zoom + 12MP, f/2.2 (ultrawide), Front Camera: 12MP, f/1.9 (wide)
  • 2G: 850/900/1800/1900, 3G: HSDPA 850/900/1700(AWS)/1900/2100, 4G LTE: 1/2/3/4/5/7/8/12/13/14/17/18/19/20/25/26/28/29/30/32/34/38/39/40/41/42/46/48/53/66/71, 5G: 1/2/3/5/7/8/12/14/20/25/26/28/29/30/38/40/41/48/53/66/70/71/77/78/79/258/260/261 SA/NSA/Sub6/mmWave - Dual eSIM
  • Unlocked for freedom to choose your carrier. Compatible with both GSM & CDMA networks. The phone is unlocked to work with all GSM Carriers & CDMA Carriers Including AT&T, T-Mobile, Verizon, Sprint., Etc.
  • Wait for a meaningful element when the page has a clear completion signal: await page.locator('main').waitFor({ state: 'visible' });.

  • If content appears after a known interval, add a deliberate delay with await page.waitForTimeout(1000); adjust it to the page, and avoid treating a fixed pause as proof that all content is ready.

  • For content below the fold that loads on scroll, full-page capture may not cause every site’s lazy content to load. If missing content matters, scroll through the page before capturing or use a site-specific readiness condition.

Screenshot output can vary with the host operating system, browser version, settings, hardware, power source, and headless mode. For visual comparisons, create and update baselines in a consistent environment, and inspect a new baseline before accepting it. Playwright’s visual comparisons guide discusses these sources of rendering differences.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A one-off file capture and a visual regression assertion are different workflows. Use page.screenshot() to save an image directly. Use Playwright Test’s expect(page).toHaveScreenshot() when you want an assertion comparing a page against a screenshot baseline.

Best Value
Apple iPhone 15, 128GB, Black - Unlocked (Renewed)
  • 6.1inch Super Retina XDR display. Aluminum with color-infused glass back. Ring/Silent switch
  • Dynamic Island. A magical way to interact with iPhone. A16 Bionic chip with 5-core GPU
  • Advanced dual-camera system. 48MP Main | Ultra Wide. Super-high-resolution photos (24MP and 48MP). Next-generation portraits with Focus and Depth Control. 4X optical zoom range
  • Emergency SOS via satellite. Crash Detection. Roadside Assistance via satellite
  • Up to 26 hours video playback. USB C, Supports USB 2. Face ID
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot common problems

  • “Cannot read properties of undefined” for a device name: The installed Playwright version may not include that registry entry, or the name may be misspelled. Check the available device names for that installed version and use one of those, or configure an explicit viewport.

  • The capture has desktop dimensions: Check that the context was created with the device profile or viewport before the page was created. When overriding a profile, ensure the explicit viewport appears after the spread.

  • The image stops at the first screen: That is the default viewport capture. Set fullPage: true when you need the scrollable page.

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • The image is unexpectedly large: Check whether scale: 'device' is producing device-pixel output. Choose scale: 'css' for one output pixel per CSS pixel.

  • Images or page content are missing: The page may still be rendering after navigation, or the content may be lazy-loaded. Wait for a relevant selector or condition; for below-the-fold content, scroll before capture if needed.

  • Visual snapshots differ between machines or runs: Rendering can depend on the browser and host environment. Keep the environment consistent and review changed baselines rather than assuming the page alone caused the difference.

Or skip the browser setup

For a screenshot without installing or configuring Playwright, ScreenshotNeo accepts a URL in one GET request and returns an image or PDF. For example, this cURL call saves a WebP screenshot:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Quick Recap

Bestseller No. 1
Apple iPhone 15 Pro, 128GB, Blue Titanium - Unlocked (Renewed)
Apple iPhone 15 Pro, 128GB, Blue Titanium - Unlocked (Renewed)
Dynamic Island. A magical way to interact with iPhone. A17 Pro chip with 6-core GPU; Emergency SOS via satellite. Crash Detection. Roadside Assistance via satellite
$528.80
Bestseller No. 2
Apple iPhone 15 Pro, 128GB, Black Titanium - Unlocked (Renewed)
Apple iPhone 15 Pro, 128GB, Black Titanium - Unlocked (Renewed)
Dynamic Island. A magical way to interact with iPhone. A17 Pro chip with 6-core GPU; Emergency SOS via satellite. Crash Detection. Roadside Assistance via satellite
$534.22
Bestseller No. 5
Apple iPhone 15, 128GB, Black - Unlocked (Renewed)
Apple iPhone 15, 128GB, Black - Unlocked (Renewed)
Dynamic Island. A magical way to interact with iPhone. A16 Bionic chip with 5-core GPU; Emergency SOS via satellite. Crash Detection. Roadside Assistance via satellite
$405.00
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp

See the ScreenshotNeo API documentation for request options. ScreenshotNeo removes cookie/consent banners, newsletter popups, and chat widgets before capture; bot checks, blank pages, and failed loads are not billed. It also has an MCP server for AI agents, and its Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000. Visit ScreenshotNeo for product details, or sign up free.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.