Use Playwright Test projects with mobile device profiles to capture and compare iPhone-like and Android-like website screenshots. This is browser emulation—not proof that a physical iPhone or Android phone was tested. For repeatable visual regression checks, save a baseline with toHaveScreenshot(), run tests in a consistent environment, and review any changed images before updating the baseline.
Choose the kind of mobile test you need
Playwright offers two distinct approaches. For responsive layout checks and screenshot regression, configure browser projects with device profiles. For direct interaction with Android Chrome or Android WebView on a device or emulator, use Playwright’s experimental Android API.
| Approach | Best for | What it represents |
|---|---|---|
| Browser project with a mobile profile | Repeatable responsive-layout and visual-regression tests | Browser emulation using profile settings such as viewport, screen size, user agent, and touch behavior. Playwright describes mobile emulation for Chrome on Android and Mobile Safari. Playwright emulation guide; installation guide |
| Playwright Android API | Checks that need to attach to Android Chrome or WebView on an Android device or AVD | Direct Android automation through ADB; the API is experimental. Playwright Android API |
A named profile such as “iPhone 13” sets browser context parameters; it does not reproduce every property of a physical handset. The official Playwright setup described here supports Mobile Safari emulation, but does not establish a corresponding direct physical-iPhone automation workflow.
Set up Playwright projects for mobile profiles
Install Playwright Test and its browser binaries using the installation instructions for your project. Profile names come from Playwright’s device registry, so check the registry for the version installed in your project rather than assuming a particular model remains available. The emulation guide documents profile settings including user agent, screen size, viewport, touch capability, locale, timezone, geolocation, permissions, and color scheme. See Playwright’s emulation guide.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →#1 Best Overall
- Cruise-Ready IPX8 Waterproof Protection: Fully sealed IPX8 waterproof pouch protects your phone from splashes, rain, pool water and beach sand—perfect for cruises, pool decks, water rides, beach days and tropical excursions.
- Touch-Friendly Screen for Easy Use: Clear and responsive touch window lets you use your phone, take photos/videos, check maps or read messages without removing it from the pouch—ideal for capturing moments during cruise trips.
- Upgraded 8.9" Universal Fit — Works with Most Phones with Case On: The roomy 8.9-inch inner space fits nearly all iPhones and large Android phones even with protective cases installed. No need to remove your case before sealing—more convenient for travel and everyday use.
- Secure Double-Lock Seal for All Water Activities: Reinforced dual-lock system prevents water, sand, dust and dirt from entering—reliable for beach outings, snorkeling, kayaking, water parks and cruise excursions.
- Slim, Lightweight & Travel-Easy — 2-Pack for Families: Flat, compact and easy to pack into pockets, lanyards or beach bags. Comes in a 2-pack, perfect for couples, friends or keeping a backup during travel and cruise vacations.
In playwright.config.ts, import the device registry and add projects for the profiles you want. This example uses the documented “iPhone 13” profile; add or change names to match the registry in your installed version.
import { defineConfig, devices } from '@playwright/test';
export default defineConfig({
testDir: './tests',
projects: [
{
name: 'mobile-safari-emulation',
use: {
...devices['iPhone 13'],
},
},
{
name: 'android-chromium-emulation',
use: {
...devices['Pixel 5'],
},
},
],
});
Projects are logical test groups with their own configuration; they let the same suite run under different browser and device settings. The example’s names are version-sensitive: confirm them in the device registry for your installed Playwright release. For project configuration details, see Playwright projects.
Override a profile when needed
Spread a device profile into use, then override only the setting you intend to change. For example, setting a viewport explicitly lets you test a different responsive breakpoint while keeping the rest of the profile settings.
use: {
...devices['iPhone 13'],
viewport: { width: 390, height: 844 },
},
isMobile affects whether the page’s meta viewport tag is taken into account and whether touch events are enabled. Keep those behaviors in mind when adjusting profile settings. Playwright’s emulation documentation describes the available context options.
Record a test with a device profile
Playwright’s test generator can record a test using a device configuration. For example:
Rank #2
- [Three-in-one phone holder for car] Our phone holder for car allows you to install it on the dashboard, windshield or vent without leaving any traces. This mobile phone holder provides you with a simple way to securely fix your mobile phone in place, and is ideal for cars, trucks, SUVs, etc.
- [Strong Adhesive Suction] The phone holder for car uses a powerful 3-layer viscous gel and a 1-step locking mechanism to provide strong suction on a smooth surface without leaving any residue. They will not fall off even when turning, bumping or driving at high speeds, and using TPU material can withstand temperatures from -4°F to 203°F. To restore the stickiness, simply rinse with warm water and dry.Please note, most likely will not work on leather/ vinyl dashboards.
- [Easy operation, strong compatibility] One-handed lightly touch, release or lock the phone within a few seconds-super convenient to use while driving. The SUUSON car phone holder mount has adjustable feet, stronger and wider clips, making this phone holder for car suitable for all (4.0"-7.0") mobile phone and mobile phone case combinations.
- [360°view angle available] 360° ball joint and extendable telescopic arm (4.43"-7.31") allow you to adjust the phone to any angle. This cell phone holder for car allows you to use your phone in portrait and landscape mode. Avoid obstructing the line of sight during driving to ensure driving stability and safety.
- [Perfect protection, best design] The car phone holder mount is covered with a thick layer of silica gel. The unprecedented design makes the mobile device zero scratches. The internal mechanical structure ensures that the arm holds the phone firmly. No need to worry that your phone will not fall off even on the most bumpy road. If you have any product problems or installation problems, please feel free to contact us, we promise to always provide satisfactory solutions and serve you.
npx playwright codegen --device="iPhone 13" https://example.com
This helps record interactions with the selected emulated device settings. It does not create a visual-regression baseline; use a screenshot assertion for that. See Playwright’s test generator documentation.
Capture screenshots and compare them against a baseline
Use expect(page).toHaveScreenshot() in a Playwright Test. On its first run, Playwright writes a reference image; on later runs, it compares the current image with that baseline. Treat the baseline as reviewed test data: check the image diff and update references only when a change is intentional.
import { test, expect } from '@playwright/test';
test('mobile home page matches its visual baseline', async ({ page }) => {
await page.goto('https://example.com');
await expect(page).toHaveScreenshot('home-page.png');
});
Run the test with npx playwright test. To accept an intentional visual change, use Playwright’s snapshot update workflow, then inspect the changed reference images before committing them. See Playwright’s visual comparisons guide for screenshot assertions, baseline handling, and comparison options.
Choose the screenshot scope
- Viewport: captures the visible screen. Use this to check what a visitor sees without scrolling.
- Element: captures a selected component or region. Use this to isolate a navigation menu, card, or other specific part of the page.
- Full page: captures the full scrollable page. Use this when content below the fold matters; it answers a different question from a viewport capture.
Playwright’s screenshot tooling documents viewport, element, full-page, and image scale choices. CSS-pixel scale is the documented default; device-pixel scale produces a higher-resolution image. Choose the scale that matches how the image will be reviewed rather than treating the two as interchangeable. Playwright screenshot options.
Keep visual comparisons repeatable
Pixel differences can come from the test environment as well as an application change. Playwright’s visual comparison guidance notes that rendering may vary with the host operating system, browser version, settings, hardware, power source, and headed or headless mode. Generate baselines and run comparisons in the same environment wherever possible. Playwright visual comparisons.
- Keep the operating system, browser version, Playwright version, and headed/headless mode consistent between baseline creation and test runs.
- Investigate dynamic content, such as changing text or timestamps, before increasing a diff threshold.
- Use
maxDiffPixelsor a custom stylesheet to filter volatile elements only when you have identified the source of noise. These controls tune comparisons; they do not explain why a page changed. - Review image diffs before updating baselines so that an unwanted visual regression is not accepted as the new reference.
When to automate on a real Android device
Use the Android API when the test specifically needs Android Chrome or Android WebView attached to an Android device or an AVD emulator, rather than a browser context configured with a mobile profile. Playwright marks this API experimental, so verify its setup against the documentation for the Playwright release you use. Playwright Android API.
Documented prerequisites
- An Android device or AVD Emulator.
- An authenticated ADB daemon; raw USB operation is not supported without ADB.
- Chrome 87 or newer.
- The “Enable command line on non-rooted devices” option enabled at
chrome://flags.
These requirements are version-sensitive; check the current Android API page before setting up a device. The documentation also notes that the device must be awake for screenshots and that not all tests have been run against the device.
Troubleshoot common screenshot problems
The screenshot differs across runs
Check whether the baseline and current run use different operating systems, browser versions, settings, hardware, power conditions, or headed/headless modes. Then check the page for dynamic content. Keep environments consistent and filter volatile content deliberately rather than immediately widening the pixel threshold. Visual comparison guidance.
The device profile name is not recognized
Device registry entries can change across Playwright versions. Check the registry and spelling for the version installed in the project, then use an available profile or define the needed context settings explicitly. Device emulation reference.
The layout does not behave like a mobile page
Confirm the project is using the intended profile, including its viewport, screen size, user agent, and touch settings. If you overrode isMobile or the viewport, check how that affects the meta viewport tag and touch events.
Rank #4
- 15W Fast Charge for the Morning Rush: Save up to 45 minutes with the INIU Wireless Charger. Powered by AirFuel tech, it’s ideal for commuters needing a rapid power boost before leaving, eliminating the frustration of slow charging.
- Sleep-Friendly for Nightstands: The self-adaptive LED dims in the dark and brightens by day. Perfect for light sleepers, it keeps you informed of your charging status without harsh glare disturbing your rest.
- Dual Coils for Desk & Entertainment: A wider charging area means no more finding the "sweet spot." A must-have office desk setup, letting you FaceTime in portrait or watch videos in landscape without losing power.
- NTC Temp°Guard for Battery Health: Smart, real-time temperature control prevents overheating. Heavy users can safely leave phones charging overnight, solving the pain of heat-induced battery damage.
- Perfect for Every Household: Auto-adapts up to 15W for compatible iOS and Android phones, making it the ideal shared wireless charger for families and guests.
An Android screenshot cannot be captured
For direct Android automation, confirm that ADB is authenticated, the device or AVD is available and awake, and the documented Chrome and command-line flag prerequisites are met. The Android workflow is experimental and requires ADB; a browser profile project is the simpler path when emulation is sufficient. Android API requirements and limitations.
Recommended Free Tools
A baseline update hides an unwanted change
Do not update references just to make a failing test pass. Inspect the actual screenshot and diff first; update a baseline only after deciding the visual change is expected.
Or skip the browser setup
If you need a screenshot without configuring Playwright projects, ScreenshotNeo takes a URL in one GET request and returns an image or PDF. The same parameter names used by other screenshot APIs work, which can make switching easier. See the ScreenshotNeo screenshot API and MCP server.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
See the ScreenshotNeo API documentation for request options. Before capture, it can accept cookie or consent banners and remove 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, and responses identify the page verdict and billing status in headers. Its MCP server offers take_screenshot, get_page_info, and capture_pdf for 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 1,000 free screenshots a month—no card required.
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Clear out junk files and repair common Windows errorsFree Scan →Frequently Asked Questions
Does an iPhone Playwright profile test a physical iPhone?
No. It configures browser emulation; the profile name does not show that a physical handset was used.
Can Playwright directly automate iPhone hardware in this workflow?
The Playwright documentation covered here establishes Mobile Safari emulation, not a corresponding direct physical-iPhone automation path.
Do I need to buy an Android phone for direct Android checks?
No. The documented Android API supports an Android device or an AVD Emulator.
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.

