Prompt
How do I automate browser testing across Chrome, Firefox, and Edge?
Latest observation
Oct 26, 2026
OpenAI APIWeb search: off
A common way to automate browser testing across Chrome, Firefox, and Edge is to use a cross-browser testing framework like Playwright or Selenium. For most modern projects, I’d recommend Playwright because it’s fast, reliable, and has built-in support for all three browsers.
Best option: Playwright
Why Playwright?
- Supports Chromium (Chrome/Edge), Firefox, and WebKit
- Easy to run the same test in multiple browsers
- Good auto-waiting, reducing flaky tests
- Works well in CI/CD
Basic setup
1) Install Playwright
npm init playwright@latest
Or if you already have a Node project:
npm install -D @playwright/test
npx playwright install
2) Configure browsers
Playwright can run tests across browsers via the config file.
Example playwright.config.ts:
import { defineConfig, devices } from '@playwright/test';
export default defineConfig({
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},
{
name: 'firefox',
use: { ...devices['Desktop Firefox'] },
},
{
name: 'edge',
use: { channel: 'msedge' },
},
],
});
3) Write a test
Example tests/example.spec.ts:
import { test, expect } from '@playwright/test';
test('homepage has title', async ({ page }) => {
await page.goto('https://example.com');
await expect(page).toHaveTitle(/Example Domain/);
});
4) Run tests in all browsers
npx playwright test
Alternative: Selenium
Selenium is another popular choice, especially if you need:
- Existing Selenium/Grid infrastructure
- Language support beyond JavaScript/TypeScript
- Compatibility with older test suites
Example using Selenium with Node.js
Install:
npm install selenium-webdriver
Example:
const { Builder } = require('selenium-webdriver');
const chrome = require('selenium-webdriver/chrome');
const firefox = require('selenium-webdriver/firefox');
const edge = require('selenium-webdriver/edge');
async function testBrowser(browserName) {
let builder = new Builder().forBrowser(browserName);
if (browserName === 'chrome') {
builder.setChromeOptions(new chrome.Options());
} else if (browserName === 'firefox') {
builder.setFirefoxOptions(new firefox.Options());
} else if (browserName === 'MicrosoftEdge') {
builder.setEdgeOptions(new edge.Options());
}
const driver = await builder.build();
try {
await driver.get('https://example.com');
console.log(await driver.getTitle());
} finally {
await driver.quit();
}
}
(async () => {
await Promise.all([
testBrowser('chrome'),
testBrowser('firefox'),
testBrowser('MicrosoftEdge'),
]);
})();
Recommended approach for CI
Run tests in a pipeline like GitHub Actions, Azure DevOps, or GitLab CI.
Example GitHub Actions for Playwright:
name: Playwright Tests
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm ci
- run: npx playwright install --with-deps
- run: npx playwright test
Practical tips
- Use stable selectors like
data-testid - Prefer explicit assertions over fixed delays
- Test critical flows in all browsers, not necessarily every tiny UI detail
- Keep browser-specific workarounds isolated
If you want, I can give you:
- a Playwright starter template,
- a Selenium version in your preferred language, or
- a CI pipeline example for GitHub Actions/Azure DevOps.