1. Introduction to Playwright TypeScript Multi-Browser Configuration
Modern web applications must work correctly across different browsers and devices. A website that works perfectly in Chrome may display layout problems in Firefox or Safari.
For QA Automation Engineers and SDETs, testing applications across multiple browsers is an important part of end-to-end testing.
This is where Playwright TypeScript multi-browser config becomes useful.
Playwright supports three major browser engines: Chromium, Firefox, and WebKit. Using Playwright projects, you can configure automated tests to execute across multiple browsers without maintaining separate test scripts.
For example, imagine developing an e-commerce application. Your application should support:
- Google Chrome users.
- Mozilla Firefox users.
- Safari users.
- Mobile users accessing the website through supported mobile browser configurations.
Instead of creating separate automation frameworks for each browser, you can configure multiple browser projects inside a single playwright.config.ts file.
In this tutorial, we will learn how to configure Chromium, Firefox, and WebKit using TypeScript, execute cross-browser tests, configure browser-specific settings, handle compatibility issues, and integrate multi-browser execution into CI/CD pipelines.
By the end, you will understand how to build a reusable cross-browser automation framework suitable for real-world QA projects.
2. What Is Cross-Browser Testing, and Why Is It Important?
Cross-browser testing is the process of verifying whether a web application works correctly across different browsers, browser engines, operating systems, and devices.
Different browsers may render HTML, CSS, and JavaScript differently.
For example:
- A button may appear correctly in Chrome but have different spacing in Firefox.
- A CSS layout may behave differently in Safari.
- A JavaScript feature may behave differently across browser engines.
- A responsive layout may display incorrectly on mobile devices.
Cross-browser testing helps identify these problems before applications reach production.
Benefits of Playwright Cross-Browser Testing
1. Better browser compatibility: Verify application behavior across Chromium, Firefox, and WebKit.
2. Reduced test maintenance: Reuse the same TypeScript test scripts across multiple browser projects.
3. Faster regression testing: Run browser-specific tests and identify compatibility issues early.
4. Improved application quality: Detect browser rendering, navigation, and interaction problems.
5. Better automation coverage: Combine desktop browsers and mobile device emulation within one automation framework.
For enterprise QA engineering teams, multi-browser configuration helps maintain consistent software quality across supported browsers.
3. Prerequisites and Project Setup
Before implementing Playwright TypeScript multi-browser config, install the required tools.
Prerequisites
- Node.js
- TypeScript
- Visual Studio Code
- Playwright Test
- Basic knowledge of JavaScript and TypeScript
Step 1: Create a Playwright project
Open the terminal and execute:
npm init playwright@latest
Select TypeScript when prompted.
Alternatively, install Playwright Test in an existing Node.js project:
npm install -D @playwright/test
Step 2: Install browser engines
Install the supported Playwright browsers:
On Linux CI machines, install the browsers and their system dependencies:
npx playwright install –with-deps
Step 3: Recommended project structure
Organize your automation framework as follows:
playwright-multibrowser/
│
├── tests/
│ ├── login.spec.ts
│ ├── home.spec.ts
│ └── checkout.spec.ts
│
├── pages/
│ ├── LoginPage.ts
│ └── HomePage.ts
│
├── test-data/
│ └── users.json
│
├── playwright-report/
├── test-results/
│
├── playwright.config.ts
├── package.json
└── tsconfig.json
This structure separates test scripts, page objects, test data, and configuration.
4. Understanding Playwright Browser Engines: Chromium, Firefox, and WebKit
Playwright supports three browser engines.
1. Chromium
Chromium is the open-source browser engine used by Google Chrome and several other browsers. It is useful for testing applications in Chrome-like environments.
2. Firefox
Firefox uses the Gecko engine. Testing with Firefox helps identify browser compatibility problems that may not appear in Chromium.
3. WebKit
WebKit is the browser engine used by Safari. Playwright’s WebKit project helps test Safari-related browser behavior.
Browser engines versus browser channels
These concepts are important in Playwright Browser Configuration.
| Browser engine | Browser channel | Meaning |
| Chromium | chromium | Playwright-managed Chromium |
| Chromium | chrome | Installed Google Chrome |
| Chromium | msedge | Installed Microsoft Edge |
| Firefox | firefox | Playwright-managed Firefox |
| WebKit | webkit | Playwright-managed WebKit |
A browser engine determines how web content is rendered and executed. A browser channel selects a particular browser distribution.
For example, Chromium is an engine, while Google Chrome is a browser that uses Chromium.
Important: Playwright’s bundled WebKit is useful for Safari compatibility testing, but it is not identical to testing the actual Safari application on macOS. For exact Safari validation, include real Safari testing where your project requirements demand it.
5. Configuring Multiple Browsers Using Projects in playwright.config.ts
Playwright uses the projects configuration option to execute tests across different browsers.
Each project can have its own browser, settings, timeout, and execution configuration.
Let’s create a complete multi-browser configuration.
Step 1: Open playwright.config.ts
Add the following code:
import { defineConfig, devices } from ‘@playwright/test’;
export default defineConfig({
testDir: ‘./tests’,
fullyParallel: true,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
workers: process.env.CI ? 2 : undefined,
reporter: [
[‘list’],
[‘html’, { open: ‘never’ }]
],
use: {
baseURL: ‘https://example.com’,
trace: ‘retain-on-failure’,
screenshot: ‘only-on-failure’,
video: ‘retain-on-failure’
},
projects: [
{
name: ‘chromium’,
use: {
…devices[‘Desktop Chrome’]
}
},
{
name: ‘firefox’,
use: {
…devices[‘Desktop Firefox’]
}
},
{
name: ‘webkit’,
use: {
…devices[‘Desktop Safari’]
}
}
]
});
Step 2: Understand the configuration
Let’s understand the important configuration properties.
- testDir: Specifies the folder containing test files.
- fullyParallel: Allows independent tests to run in parallel.
- forbidOnly: Prevents accidental focused tests in CI.
- retries: Retries failed tests.
- workers: Controls the number of parallel workers.
- reporter: Generates test execution reports.
- baseURL: Defines the application URL.
- trace: Captures execution traces.
- projects: Defines browser-specific configurations.
The configuration creates three browser projects:
- Chromium
- Firefox
- WebKit
The same test files are executed in all three projects.
6. Setting Browser-Specific Options, Devices, and Test Settings
Sometimes, different browsers require different configuration settings.
For example, you may want to execute Chromium tests with one viewport size and Firefox tests with another.
You can define browser-specific options inside individual projects.
Example: Configure different viewport sizes
import { defineConfig } from ‘@playwright/test’;
export default defineConfig({
projects: [
{
name: ‘chromium’,
use: {
browserName: ‘chromium’,
viewport: {
width: 1920,
height: 1080
}
}
},
{
name: ‘firefox’,
use: {
browserName: ‘firefox’,
viewport: {
width: 1366,
height: 768
}
}
},
{
name: ‘webkit’,
use: {
browserName: ‘webkit’,
viewport: {
width: 1440,
height: 900
}
}
}
]
});
This configuration allows different viewport settings for different browsers.
Example: Configure mobile device emulation
Playwright also supports device emulation.
For example, you can test your application using an iPhone-like or Android-like browser configuration.
import { defineConfig, devices } from ‘@playwright/test’;
export default defineConfig({
projects: [
{
name: ‘chromium-desktop’,
use: {
…devices[‘Desktop Chrome’]
}
},
{
name: ‘iphone’,
use: {
…devices[‘iPhone 13’]
}
},
{
name: ‘android’,
use: {
…devices[‘Pixel 7’]
}
}
]
});
Device descriptors configure properties such as viewport, user agent, screen size, and touch behavior.
Device emulation does not replace testing on actual physical devices. It is useful for responsive and mobile browser testing.
7. Running Tests Across All Browsers and Selecting Individual Projects
After configuring Playwright projects, you can execute tests using simple CLI commands.
Run tests in all configured browsers:
npx playwright test
Run tests only in Chromium:
npx playwright test –project=chromium
Run tests only in Firefox:
npx playwright test –project=firefox
Run tests only in WebKit:
npx playwright test –project=webkit
Run a specific test file across all browsers:
npx playwright test tests/login.spec.ts
Run a specific test file in Chromium:
npx playwright test tests/login.spec.ts –project=chromium
Run tests in headed mode:
npx playwright test –headed
Open the HTML report:
npx playwright show-report
These commands are useful when debugging browser-specific issues or executing regression testing selectively.
8. Handling Browser-Specific Test Failures and Compatibility Issues
One challenge in cross-browser testing is that an application may behave differently across browser engines.
For example, a login button may be visible in Chromium but have a different layout in WebKit.
Consider the following test:
import { test, expect } from ‘@playwright/test’;
test(‘verify login button’, async ({ page }) => {
await page.goto(‘/login’);
const loginButton = page.getByRole(‘button’, {
name: ‘Login’
});
await expect(loginButton).toBeVisible();
await expect(loginButton).toBeEnabled();
});
This test verifies that the login button is visible and enabled across all configured browser projects.
If the test fails only in WebKit, investigate:
- CSS compatibility.
- Font rendering.
- Viewport differences.
- Browser-specific JavaScript behavior.
- Application loading and timing.
- Unsupported browser features.
Avoid immediately adding browser-specific waits or skipping failing tests. First identify the actual cause.
Example: Browser-specific test behavior
Sometimes a feature is supported only in certain browsers.
You can conditionally execute a test:
import { test, expect } from ‘@playwright/test’;
test(‘browser-specific validation’, async ({ page, browserName }) => {
await page.goto(‘/dashboard’);
if (browserName === ‘webkit’) {
console.log(‘Running WebKit-specific validation’);
}
await expect(
page.getByRole(‘heading’, {
name: ‘Dashboard’
})
).toBeVisible();
});
Use browser-specific conditions only when there is a genuine difference in expected behavior. Avoid hiding application defects through unnecessary conditional logic.
9. Configuring Parallel Execution, Retries, and Reporting
When running tests across three browsers, execution time can increase.
For example, if a regression suite contains 100 tests, Playwright may execute those tests in three browser projects.
That means the suite can involve approximately 300 test executions.
Parallel execution helps reduce the overall execution time.
Example: Configure parallel execution
import { defineConfig } from ‘@playwright/test’;
export default defineConfig({
fullyParallel: true,
workers: process.env.CI ? 2 : 4,
retries: process.env.CI ? 2 : 0,
reporter: [
[‘html’],
[‘list’]
]
});
Important configuration options:
| Option | Purpose |
| fullyParallel | Enables parallel execution of independent tests |
| workers | Controls concurrent workers |
| retries | Retries failed tests |
| reporter | Generates execution reports |
| trace | Captures debugging information |
Best practices for parallel execution
- Start with a small number of workers in CI.
- Avoid sharing mutable test data between workers.
- Use independent test accounts where necessary.
- Avoid fixed waits.
- Use retries to diagnose intermittent failures, not to hide them.
- Monitor CPU and memory consumption.
- Run critical browser combinations first.
A useful strategy is to execute Chromium on every pull request and run all three browser projects during scheduled regression testing. For critical applications, run all supported browsers on every pull request if execution time permits.
10. Integrating Multi-Browser Tests with GitHub Actions and Jenkins
Multi-browser testing becomes more useful when integrated into CI/CD pipelines.
You can automatically execute browser tests whenever developers push code or create pull requests.
GitHub Actions example
Create .github/workflows/playwright.yml:
name: Playwright Cross Browser Tests
on:
push:
pull_request:
jobs:
test:
timeout-minutes: 30
runs-on: ubuntu-latest
steps:
– uses: actions/checkout@v4
– uses: actions/setup-node@v4
with:
node-version: 22
– name: Install dependencies
run: npm ci
– name: Install Playwright browsers
run: npx playwright install –with-deps
– name: Run all browser tests
run: npx playwright test
– name: Upload test report
if: always()
uses: actions/upload-artifact@v4
with:
name: playwright-report
path: playwright-report/
if-no-files-found: ignore
This workflow installs dependencies, downloads the required browsers, executes all configured projects, and uploads the HTML report.
Jenkins pipeline example
You can also execute Playwright multi-browser tests using Jenkins.
Create a Jenkinsfile:
pipeline {
agent any
stages {
stage(‘Checkout’) {
steps {
checkout scm
}
}
stage(‘Install Dependencies’) {
steps {
sh ‘npm ci’
}
}
stage(‘Install Browsers’) {
steps {
sh ‘npx playwright install –with-deps’
}
}
stage(‘Execute Tests’) {
steps {
sh ‘npx playwright test’
}
}
}
post {
always {
archiveArtifacts artifacts:
‘playwright-report/**’,
allowEmptyArchive: true
}
}
}
For reliable CI execution, use a compatible Linux agent with the required browser dependencies and sufficient resources.
11. Common Configuration Mistakes and Troubleshooting
| Problem | Possible reason | Solution |
| Browser not launching | Browser binaries missing | Run npx playwright install |
| Firefox tests failing | Browser-specific incompatibility | Inspect Firefox behavior and traces |
| WebKit layout issues | CSS differences | Verify browser compatibility |
| Tests execute only once | Incorrect project configuration | Check the projects array |
| CI tests are slow | Too many workers or limited resources | Tune worker count |
| HTML report missing | Reporter not configured | Add the HTML reporter |
| Device project failing | Incorrect device descriptor | Check the installed Playwright device list |
Debugging browser-specific failures
When a test fails in one browser, run only that project:
npx playwright test –project=webkit –headed
Enable tracing for failures:
use: {
trace: ‘retain-on-failure’,
screenshot: ‘only-on-failure’
}
Review the trace using Playwright Trace Viewer:
npx playwright show-trace test-results/example/trace.zip
This helps identify whether the problem is related to navigation, element visibility, browser rendering, or application behavior.
12. Best Practices for Playwright TypeScript Multi-Browser Config
Follow these recommendations when building professional automation frameworks:
- Use Playwright projects to manage browser configurations.
- Reuse the same test scripts across supported browsers.
- Keep browser-specific settings inside project configurations.
- Use meaningful project names.
- Test desktop and mobile layouts separately.
- Avoid unnecessary browser-specific test conditions.
- Use parallel execution carefully.
- Configure retries and tracing for CI environments.
- Validate application compatibility before changing automation scripts.
- Keep browser versions and Playwright dependencies updated.
For a scalable automation architecture, combine multi-browser configuration with reusable fixtures, Page Object Model, and centralized reporting.
Explore our Playwright Framework Design pillar guide for a complete framework architecture.
13. Frequently Asked Questions
Q1. Is Playwright TypeScript multi-browser config suitable for beginners?
Yes. Beginners can start with three simple projects for Chromium, Firefox, and WebKit and gradually learn advanced browser configurations.
Q2. What are the benefits of Playwright TypeScript multi-browser config?
It allows testers to reuse automation scripts, identify browser compatibility problems, improve regression coverage, and reduce framework maintenance.
Q3. How do I get started with Playwright TypeScript multi-browser config?
Install Playwright, configure Chromium, Firefox, and WebKit inside the projects array of playwright.config.ts, and execute npx playwright test.
Q4. Can Playwright run tests in Chrome, Firefox, and Safari?
Yes. Playwright supports Chromium, Firefox, and WebKit. WebKit provides Safari-oriented engine testing, although it is not identical to running actual Safari.
Q5. What are Playwright projects?
Projects are named configurations that allow the same test suite to run with different browsers, devices, environments, or settings.
Q6. What is the difference between Chromium and Chrome?
Chromium is an open-source browser project and engine. Google Chrome is a browser built using Chromium with additional Google-specific components.
Q7. Can Playwright perform mobile browser testing?
Yes. Playwright supports device emulation using predefined device descriptors and browser-specific configurations.
Q8. How do I run only Firefox tests?
Execute npx playwright test –project=firefox.
Q9. Can Playwright execute tests in parallel across browsers?
Yes. Configure workers and parallel execution settings to control how tests execute across projects.
Q10. Is Playwright suitable for cross-browser regression testing?
Yes. It is useful for validating application functionality and browser compatibility across multiple browser engines.
