Automation Testing · Professional Practice

Cross-Browser Testing

Users browse on different browsers, devices and screen sizes. Cross-browser testing makes sure everyone gets a working site.

Advanced 5 min Lesson 18 of 24
Before you start:Playwright Test Runner
0/24 in Automation Testing
On this page · 5 min · Advanced

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#

TypeScriptplaywright.config.ts (projects) Illustrative
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);
Expected output
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#

  1. Pick targets from real usage data.
  2. Define one project per target.
  3. Run critical journeys on all; full suite on the main browser.
  4. 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#

Testing only on the developer’s browser

Safari and mobile bugs then reach users first.

Running the entire suite on every browser

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
Text Illustrative
WebKit.

Mini quiz#

Cross-Browser Testing quizMultiple choice Question 1 of 1

How should you choose which browsers to test?

Score so far: 0/0

Want more? Practise all Automation Testing MCQs · Automation Testing interview questions

My notes#

Saved in this browser.

Progress is saved in this browser. Sign in to sync.