User Agents

Web browsers and everyday web tech, explained

Verify Playwright Installation: Browsers and Runtime Guide

· 4 min read · Browsers

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

Verifying your Playwright installation ensures that the Node.js runtime is correctly configured and that the required browser binaries (Chromium, Firefox, and WebKit) are downloaded and executable. This process prevents "browser not found" errors during test execution and confirms that your environment variables are correctly mapped to the Playwright executable paths.

What You'll Need

  • Node.js installed (LTS version recommended).
  • A terminal or command prompt with administrative privileges (for installing system dependencies).
  • A project directory where Playwright has been initialized.
  • The Playwright npm package installed via npm install @playwright/test.

Step-by-Step

  1. Check Node.js and NPM Version
    Before verifying Playwright, ensure your runtime environment is stable. Open your terminal and run node -v and npm -v. Ensure the versions match the minimum requirements specified in the current Playwright documentation.
  2. Verify Package Installation
    Check your package.json file to ensure @playwright/test is listed under devDependencies. If it is missing, run npm install -D @playwright/test.
  3. Run the Browser Installation Command
    Playwright does not install browsers automatically during the npm install phase to keep package sizes small. Execute npx playwright install to download the specific versions of Chromium, Firefox, and WebKit that correspond to your current Playwright version.
  4. Verify System Dependencies
    On Linux or CI environments, browsers require specific system libraries to run. Run npx playwright install-deps. This command detects your OS and installs the necessary shared libraries (like libgbm or nss) required for the headless browsers to launch.
  5. Execute a Basic Smoke Test
    The most reliable way to verify the runtime and browser integration is to run the default example test. Execute npx playwright test. If you see a "Passed" result for the example tests, your runtime and browsers are fully functional.
  6. Inspect Browser Binaries Location
    If you need to verify where the browsers are physically stored, you can check the Playwright cache folder. On Windows, this is typically %USERPROFILE%\AppData\Local\ms-playwright; on macOS, ~/Library/Caches/ms-playwright; and on Linux, ~/.cache/ms-playwright.
  7. Run in Headed Mode for Visual Confirmation
    To visually confirm the browser launches and renders a page, run npx playwright test --headed. This forces the browser to open a visible window rather than running in the default headless mode.

Common Mistakes

  • Skipping install-deps: Users often run npx playwright install but forget install-deps. This leads to errors stating that a shared library (e.g., libatk-1.0.so.0) is missing.
  • Version Mismatch: Updating the @playwright/test npm package without re-running npx playwright install. Each version of Playwright is tied to a specific browser build; using an old browser with a new runtime will cause execution failures.
  • Incorrect Pathing: Attempting to use a system-installed version of Chrome or Firefox instead of the Playwright-bundled binaries, which can lead to inconsistent test results.
  • Permission Issues: Running the installation in a directory where the user does not have write permissions, causing the browser download to fail silently or partially.

Tips

  • Use the Playwright Inspector: Run npx playwright test --debug to open the Playwright Inspector. This verifies not only the browser but also the runtime's ability to step through code and interact with the DOM.
  • Environment Variables: If you need to store browsers in a custom location (e.g., a shared network drive), set the PLAYWRIGHT_BROWSERS_PATH environment variable before running the install command.
  • Selective Installation: If you only need one browser to save disk space, use npx playwright install chromium instead of installing all three.

Troubleshooting

If your verification fails, follow these steps based on the error message:

  • "Executable doesn't exist" error: This means the browser binaries are missing. Run npx playwright install. If you are using a specific browser, ensure you didn't accidentally filter it out in your playwright.config.ts.
  • "Browser closed unexpectedly" or Segmentation Faults: This usually indicates a missing system dependency. Run npx playwright install-deps with sudo/administrative privileges.
  • Timeouts during browser launch: Check if a firewall or corporate proxy is blocking the download of browser binaries. You may need to configure an HTTPS_PROXY environment variable.
  • Node.js Runtime Errors: If you see syntax errors (like Unexpected token '?'), your Node.js version is too old for the current Playwright version. Update Node.js to the latest LTS.

Frequently Asked Questions

Do I need to install Chrome separately?

No. Playwright downloads its own modified versions of Chromium, Firefox, and WebKit. These are optimized for automation and are independent of the browsers you use for daily surfing.

How do I check which version of Playwright I am using?

You can check the version by running npm list @playwright/test in your project terminal.

Why does npx playwright install take so long?

Playwright downloads full browser binaries to ensure consistency across different machines. Depending on your internet speed, downloading three browsers can take several minutes.

Can I verify the installation without writing a test?

Yes, running npx playwright install followed by npx playwright test (using the default example tests provided during initialization) verifies the entire stack without requiring custom code.

Does the installation differ between Windows and Linux?

The core process is the same, but Linux users must almost always run npx playwright install-deps to install the necessary OS-level libraries that Windows typically includes by default.