Cross-Browser Testing
Users browse on different browsers, devices and screen sizes. Cross-browser testing makes sure everyone gets a working site.
On this page · 5 min · Advanced
On this page
- Learning objectives
- Explanation
- Code example
- Step by step
- Real-world use
- Common mistakes
- Best practices
- Remember this
- Practice exercise
- Mini quiz
- Related topics
- My notes
- Reading time
- 5 min
- Difficulty
- Advanced
- Updated
- Oct 29, 2026
Related tutorials
Learning objectives#
- Choose browsers and devices from data
- Run tests across browsers with Playwright
- Scale with Selenium Grid or cloud labs
- Test responsive layouts
Explanation#
Use your analytics to pick the browsers and devices that cover most users (e.g. Chrome Android, Safari iOS, Chrome desktop, Edge).
Playwright projects run the same tests in Chromium, Firefox and WebKit (Safari’s engine) and emulate devices.
Selenium Grid or cloud services (BrowserStack, Sauce Labs, LambdaTest) provide real browsers and devices in parallel.
Responsive checks: key pages at phone, tablet and desktop widths with no horizontal scrolling.
Code example: Browser and device matrix#
projects: [
{ name: 'chrome', use: { ...devices['Desktop Chrome'] } },
{ name: 'firefox', use: { ...devices['Desktop Firefox'] } },
{ name: 'safari', use: { ...devices['Desktop Safari'] } },
{ name: 'android', use: { ...devices['Pixel 7'] } },
{ name: 'iphone', use: { ...devices['iPhone 14'] } },
],
// Responsive check inside a test
// await page.setViewportSize({ width: 360, height: 800 });
// const scrollWidth = await page.evaluate(() => document.documentElement.scrollWidth);
// expect(scrollWidth).toBeLessThanOrEqual(360);
The same smoke tests run on five browser/device combinations in parallel, plus a no-horizontal-scroll check at 360 px.
This example is illustrative. Copy or download it and run it in your own environment; the expected output is shown above.
Step-by-step explanation#
- Pick targets from real usage data.
- Define one project per target.
- Run critical journeys on all; full suite on the main browser.
- Add viewport checks for responsive layouts.
Real-world use case#
An Indian e-commerce site prioritises Chrome on mid-range Android phones, which make up most of its traffic.
Common mistakes#
Safari and mobile bugs then reach users first.
Expensive. Run critical paths everywhere, full suite on one.
Best practices#
- Choose targets from analytics
- Critical journeys on every target
- Real devices for final checks
- Automated responsive checks
Remember this#
Analytics decide the matrix.
Playwright: Chromium, Firefox, WebKit + devices.
Critical paths everywhere.
Practice exercise#
Your task: Which Playwright engine represents Safari?
Show solution
WebKit.
Mini quiz#
How should you choose which browsers to test?
Want more? Practise all Automation Testing MCQs · Automation Testing interview questions
My notes#
Saved in this browser.