Check Playwright Browser Installation in Node.js and Python
In this article
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
- Verify Node.js Playwright Installation
Open your terminal and navigate to a Node.js project directory. Runnpm list playwright. If Playwright is installed, you’ll see its version. If not, install it withnpm install @playwright/test. - Check Installed Browsers in Node.js
Runnpx 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. - Inspect Browser Binaries Directory (Node.js)
Playwright stores browser binaries in a global cache. Runnpx playwright cache listto 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. - Trigger Browser Installation (Node.js)
If no browsers are listed, install them withnpx playwright install. This downloads Chromium, Firefox, and WebKit by default. You can install specific browsers usingnpx playwright install chromium, for example. - Verify Python Playwright Installation
Open a terminal and runpip show playwright. If installed, this displays package details including version and location. If not, install it usingpip install playwright. - Check Installed Browsers in Python
Runpython -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. - Use Playwright Command to List Browsers (Python)
Runpython -m playwright install --dry-run. This shows which browsers are expected but won’t install them. It helps identify missing components without triggering downloads. - Inspect Python Browser Cache
Runpython -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. - Install Browsers in Python
If browsers are missing, runpython -m playwright install. This downloads all required browser binaries. To install specific ones, usepython -m playwright install firefox. - Validate Installation with a Test Script
Create a minimal script in both environments. For Node.js, createtest.jswith:const { chromium } = require('playwright'); (async () => { const browser = await chromium.launch(); await browser.close(); })();
Runnode test.js. For Python, createtest.pywith:from playwright.sync_api import sync_playwright with sync_playwright() as p: browser = p.chromium.launch() browser.close()
Runpython 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
installcommands. - Running
--dry-runand 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 listandpython -m playwright cache listregularly to audit browser status. - Install browsers only when needed —
install chromiumsaves time and disk space if only one browser is required. - Set the
PLAYWRIGHT_BROWSERS_PATHenvironment 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 usingplaywright 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.