Browser and device contexts

Chromium, Firefox, WebKit, plus emulated devices with coherent viewports, touch support, scale factors, and user agents.

  • Presets Apply a coherent device preset
  • Touch Touch is available when the context enables it
  • Context, not browser Locale, timezone, color scheme, geolocation
Presets

Apply a coherent device preset

The registry keeps viewport, user agent, scale factor, touch, and mobile flags together. Pass the preset to the context instead of maintaining each option separately.

Devices package →
$iPhone = (new DeviceRegistry())->get('iPhone 15 Pro');

$context = Playwright::webkit([
    'context' => $iPhone->toArray(),
]);
Touch

Touch is available when the context enables it

A touch-enabled context exposes touchscreen input and locator taps. Use tap() when touch behavior matters; keep click() for pointer interaction.

Devices and emulation →
Context, not browser

Locale, timezone, color scheme, geolocation

Emulation is set per context, so one browser can run a French mobile user and an English desktop one side by side in the same script.

Browsers and contexts →
Next step

Move from the tour to working code.

Choose the explanation, recipe, or runnable example that matches what you need next.

Common questions

Before you wire it into a suite.

Is device emulation the same as testing on a real phone?
No. It gives you viewport, touch, user agent, and browser behavior in a controlled desktop browser. Keep real-device testing for the cases that depend on hardware or OS integration.
Should I set viewport and user agent manually?
Prefer named device presets when they match your target. They keep viewport, scale factor, touch, mobile flags, and user agent coherent.
Can one browser run multiple devices?
Yes. Create separate contexts with different device options. Each context keeps its own viewport, storage, locale, permissions, and geolocation.