Cross-browser testing is the main reason many teams still choose Selenium. The same test can drive Chrome, Firefox, Edge and Safari.
Getting it running is straightforward. Read the browser name from an environment variable:
const browser = process.env.BROWSER || 'chrome';
driver = await new Builder().forBrowser(browser).build();
Then run the suite once per browser in your build server config.
Now the part nobody tells juniors. Running everything on four browsers is usually a waste of time and money.
I worked on a suite that ran 300 tests on four browsers: 1,200 runs on every change. It took over an hour. In a year, the number of real bugs found only on Firefox and not on Chrome was three. All three were CSS problems that a much smaller set of tests would have caught.
Most modern browser differences are in layout and CSS, not in business logic. Your checkout logic behaves the same everywhere. So think about what actually differs per browser:
- Run everything on one main browser, usually the one most of your users have.
- Run a small set on the others: login, checkout, and the pages with complex layout.
- Some things need real device testing instead, especially Safari on iPhone.
There is one more thing to prepare for. When a test fails on Firefox only, your first job is to find out whether it is a real bug or a timing difference. Firefox is often slower to render, so tests with weak waits fail there first. That is useful information: a test that only fails on one browser is often a test with a hidden timing assumption, not a browser bug.
Remember this: pick one main browser for full coverage, and a small critical set for the rest.
Reference: Browsers.