User Agents

Web browsers and everyday web tech, explained

Check Playwright Browser Installation in Node.js and Python

· 5 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

Check whether Playwright browsers are installed by verifying browser binaries in both Node.js and Python environments. This ensures your automated testing workflows run without errors due to missing browser dependencies. Playwright relies on specific browser versions (Chromium, Firefox, WebKit) that must be downloaded separately after installing the library. Confirming their presence prevents runtime failures during script execution.

What You'll Need

  • Node.js installed (for JavaScript/TypeScript projects)
  • Python 3.7 or higher (for Python projects)
  • npm or yarn package manager (Node.js)
  • pip package manager (Python)
  • Playwright installed for either or both environments
  • Terminal or command prompt access

Step-by-Step

  1. Verify Node.js Playwright Installation
    Open your terminal and navigate to a Node.js project directory. Run npm list playwright. If Playwright is installed, you’ll see its version. If not, install it with npm install @playwright/test.
  2. Check Installed Browsers in Node.js
    Run npx playwright install --dry-run. This command lists all browsers Playwright expects to have installed without downloading them. If browsers appear in the list, they are either already installed or recognized. A clean output means no browsers are present.
  3. Inspect Browser Binaries Directory (Node.js)
    Playwright stores browser binaries in a global cache. Run npx playwright cache list to see which browsers are actually downloaded and their versions. This is the most reliable way to confirm installation status. If the list is empty, browsers are not installed.
  4. Trigger Browser Installation (Node.js)
    If no browsers are listed, install them with npx playwright install. This downloads Chromium, Firefox, and WebKit by default. You can install specific browsers using npx playwright install chromium, for example.
  5. Verify Python Playwright Installation
    Open a terminal and run pip show playwright. If installed, this displays package details including version and location. If not, install it using pip install playwright.
  6. Check Installed Browsers in Python
    Run python -c "import playwright; from playwright.sync_api import sync_playwright; print('Playwright loaded')". This imports Playwright and confirms the module is accessible. However, this does not verify browser binaries.
  7. Use Playwright Command to List Browsers (Python)
    Run python -m playwright install --dry-run. This shows which browsers are expected but won’t install them. It helps identify missing components without triggering downloads.
  8. Inspect Python Browser Cache
    Run python -m playwright cache list. This command mirrors the Node.js version and displays all downloaded browsers. If output includes Chromium, Firefox, and WebKit with version numbers, installation is complete.
  9. Install Browsers in Python
    If browsers are missing, run python -m playwright install. This downloads all required browser binaries. To install specific ones, use python -m playwright install firefox.
  10. Validate Installation with a Test Script
    Create a minimal script in both environments. For Node.js, create test.js with:
    const { chromium } = require('playwright'); (async () => { const browser = await chromium.launch(); await browser.close(); })();
    Run node test.js. For Python, create test.py with:
    from playwright.sync_api import sync_playwright with sync_playwright() as p: browser = p.chromium.launch() browser.close()
    Run python test.py. No errors mean browsers are correctly installed and accessible.

Common Mistakes

  • Assuming Playwright installation includes browsers — it does not; browsers must be installed separately via install commands.
  • Running --dry-run and mistaking it for actual installation — this only simulates the process.
  • Checking only module presence without verifying browser binaries — a working import doesn’t guarantee browser availability.
  • Using different user accounts or environments (e.g., sudo vs. regular user) leading to permission issues or split installations.
  • Forgetting to run install commands after updating Playwright — updates may require fresh browser binaries.

Tips

  • Use npx playwright cache list and python -m playwright cache list regularly to audit browser status.
  • Install browsers only when needed — install chromium saves time and disk space if only one browser is required.
  • Set the PLAYWRIGHT_BROWSERS_PATH environment variable to control where binaries are stored, useful in CI/CD or shared environments.
  • Run test scripts after installation to catch launch issues early, especially in headless environments.
  • Keep Playwright updated — older versions may not support newer browser binaries or commands like cache list.

Troubleshooting

If browsers appear installed but scripts fail to launch, first verify the cache list output. If empty, rerun the install command. Network issues can interrupt downloads — retry with a stable connection. On restricted systems, ensure write permissions to the cache directory (usually in user home or AppData). If using Docker or virtual environments, confirm that the Playwright install step is included in the image or environment setup. For Python, ensure the same Python interpreter used to install Playwright is used to run scripts. In Node.js, avoid global installs unless necessary — local project dependencies are more reliable. If errors mention missing executable paths, check that the Playwright package wasn't corrupted; reinstall it completely. On macOS, Gatekeeper may block unsigned binaries — allow exceptions if prompted. On Linux, missing system dependencies (like libasound) can prevent browser startup; consult Playwright’s system requirements for your distro.

Frequently Asked Questions

Does installing Playwright automatically install browsers?

No. Installing the Playwright package only adds the library. Browsers must be installed separately using playwright install or equivalent.Can I share browser binaries between Node.js and Python? Yes, but not automatically. Set PLAYWRIGHT_BROWSERS_PATH to a shared directory so both environments use the same binaries.Why does --dry-run show browsers but cache list doesn’t? The dry-run shows what would be installed. If cache list is empty, browsers are not actually downloaded. Run the install command to fix this.Do I need to install browsers every time I set up a new project? No. Playwright caches browsers globally by default. Once installed, they’re available across projects unless the cache is cleared.What happens if I don’t install the browsers? Scripts will fail at runtime with errors like 'Executable doesn't exist' or 'Browser not found'. Installation is mandatory for execution.Are the browser installations the same for Node.js and Python? Yes, the underlying binaries are identical. However, each environment manages them separately unless a shared path is configured.