Samuel Plumppu

Installing Playwright on non-Ubuntu Linux distributions

PlaywrightDistroboxTesting

Prerequisites

This guide assumes you have a container runtime like Podman (strongly recommended) or Docker already installed.

Set up distrobox

Since Playwright only supports Ubuntu, you can use Distrobox to run Playwright within an Ubuntu container. This allows you to run Playwright on your development machine despite which Linux distribution you prefer.

On Fedora, you can install it like this:

It's a good practice to separate your actual home directory from the home directories of your distrobox containers. I suggest you store them all in once place in ~/distrobox, and then create subdirectories with the actual home directories of each distrobox container:

To use distrobox, we begin by creating a new container named ubuntu and set its home directory to ~/distrobox/ubuntu. This will also install some additional packages needed for Playwright.

Next, let's enter into the ubuntu container:

NOTE: The first time you run this command it will start installing dependencies, which might take some time depending on your network.

Once this is completed, your current terminal will have access to the environment of your distrobox container called ubuntu. You can now run commands specific to the Ubuntu environment, such as:

Great! Now let's get started with Playwright.

Installing Playwright

In the same terminal with access to the ubuntu container, navigate to your project directory and run the following two commands.

First, install the system dependencies (Ubuntu packages) needed by Playwright:

Then, install the latest browsers used to run tests:

And now you're ready to start testing with Playwright!

Running tests with Playwright

NOTE: Make sure to run the Playwright tests in your native Terminal application and not in an integrated terminal such as the one in your code editor. This way, you keep the Playwright process - which spawns several browsers - separate from your code editor. This is much better for system stability and memory usage.

To get access to the ubuntu distrobox container, run the following in a new native terminal:

In the same terminal, you can then navigate to your project directory and run the tests:

And that's all - happy testing!

Thank you for reading! 🌱

Read 9 more posts or learn more about me.