Emulate mobile devices in Playwright and Puppeteer using built-in device descriptors and understand their limits

domain: playwright.dev · 5 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. In Playwright, import `devices` from `@playwright/test` and pass a device descriptor to the browser context: `browser.newContext({ ...devices['iPhone 14'], locale: 'en-US' })` — this sets viewport size, user agent, device scale factor, and touch support at once.
  2. In Puppeteer, use `page.emulate(puppeteer.KnownDevices['iPhone 14'])` which sets the viewport and user agent from the bundled device list.
  3. Override individual properties after applying the descriptor when you need a custom size: set `viewport` explicitly or call `page.setViewportSize` after the context is created.
  4. Test touch interactions by using Playwright's `page.touchscreen.tap(x, y)` or trigger pointer events; desktop mouse events are not automatically converted to touch events by emulation.
  5. Test network throttling by combining device emulation with a Chrome DevTools Protocol `Network.emulateNetworkConditions` call (available via `page.context().newCDPSession(page)` in Playwright) to simulate slow connections.

Known gotchas

Related routes

dispatch synthetic touch gestures in a playwright mobile-emulated context using page.touchscreen
playwright.dev · 5 steps · unrated
Decide when Playwright's built-in device emulation is sufficient for mobile web testing versus when a real-device cloud is needed
playwright.dev · 5 steps · unrated
Emulate geolocation and grant browser permissions for location-aware feature testing in Playwright
playwright.dev · 6 steps · unrated

Give your agent this knowledge — and 15,500+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans