Tip: Use Playwright to quickly test across multiple browsers

Published on
Authors

At some point, whether you're building web applications or assisting users with them, you'll find yourself needing to open a different version of a web browser than the one you currently have.

Testing in various browser versions can be a daunting task. For example, you might need to reproduce an issue in Safari X, Chrome Y, and Firefox Z. Installing all of these versions locally is not only unlikely but also impractical.

Introducing Playwright

Playwright is an end-to-end testing tool designed to simplify cross-browser testing. It allows you to automate browser actions as part of your test suite. One of Playwright's major advantages is that it includes pre-built binaries of major browsers for all platforms.

To get started with Playwright, run:

npx playwright@1.51.0 install

NodeJS is required.

Each Playwright release bundles specific versions of Chromium, Mozilla Firefox, and WebKit (the engine behind Safari).

For example, version 1.51.0 includes:

  • Chromium 134.0.6998.35
  • Mozilla Firefox 135.0
  • WebKit 18.4

Launching Browsers

You can launch different browser engines directly using the following commands:

Launch WebKit (Safari engine):

npx playwright@1.51.0 wk

Launch Chromium (Google Chrome and Microsoft Edge):

npx playwright@1.51.0 cr

Launch Mozilla Firefox:

npx playwright@1.51.0 ff

Managing Browser Versions

Each version of Playwright comes with its own set of bundled browser versions, giving you flexibility in testing. This capability is critical for ensuring that your application behaves consistently across different browsers and versions.

Playwright reduces the overhead of setting up a testing environment, allowing developers to focus more on writing effective tests. If you ever need to clean up your installations, you can use:

npx playwright uninstall --all`.

Conclusion

Testing across different browser versions is a challenge that many developers face. Playwright makes this process more manageable by providing built-in browser binaries and simple commands for launching them. By using Playwright, you can increase both the efficiency and effectiveness of your testing workflow and ensure a consistent user experience across all major browsers.