Chapter 58: Cross-browser and mobile emulation
Automation learning lab
Playwright Automation
Self Study Guide
Start from zero. Learn JavaScript and TypeScript, automate browsers, and build reliable end-to-end tests.
Cross-browser and mobile emulation
Projects run the same suite under different settings. Device descriptors can emulate viewport, user agent and touch settings; this does not substitute for testing real mobile devices. Configure only the projects appropriate to your requirements.
How it works
Step-by-step walkthrough
- Define desktop and mobile projects
- Run both
- Compare layout behavior
Example
import { defineConfig, devices } from '@playwright/test';
export default defineConfig({
projects: [
{ name: 'chromium', use: { ...devices['Desktop Chrome'] } },
{ name: 'mobile', use: { ...devices['Pixel 7'] } }
]
});Emulation is not equivalent to physical-device testing.
✎ Your practice task
Add a WebKit desktop project.
Knowledge check
Does mobile emulation guarantee real-device behavior?
🌐 Continue learning
60-chapter learning path
Start at chapter 1, or choose any topic. Your progress is tracked separately for each chapter.
JavaScript fundamentals
TypeScript fundamentals
Playwright • setup & locators
Playwright • interactions & assertions
Playwright • framework & debugging
Playwright • real-world automation
Interactive practice lab
Try the controls below and observe the corresponding Playwright locator instructions. This browser demo does not execute Node.js or Playwright Test; copy the code to your local Playwright project to automate it.
Task manager demo
Suggested automation
Actions on the demo update these examples. In your local test use a page that contains the same controls.
Download a standalone lab page, then serve it locally (for example with Python's http.server). Navigate to it in a Playwright test.