Playwright Installation Commands: Complete Guide for Beginners and Professionals
Installing Playwright correctly is the very first step toward building a reliable, scalable, and modern test automation framework. Whether you're starting a brand-new automation project or adding Playwright to an existing application, understanding the available installation commands will save you time and help you avoid common setup issues.
Playwright provides a powerful Command Line Interface (CLI) that makes installation incredibly simple. With just a few commands, you can create a complete Playwright project, install browsers, download system dependencies, verify your installation, and explore every available CLI option.
In this tutorial, you'll learn every important Playwright installation command with practical examples and understand when each command should be used in real-world software testing projects.
Why Learn Playwright Installation Commands?
Many beginners believe installing Playwright is simply running one command and writing tests. However, professional SDETs often need to install Playwright in different environments, including:
- Local development machines
- Existing JavaScript or TypeScript projects
- CI/CD pipelines
- Docker containers
- Linux build servers
- GitHub Actions
- Azure DevOps
- Jenkins agents
Knowing the correct installation commands ensures your automation framework is portable, maintainable, and easy for every team member to set up.
Create a New Playwright Project
The easiest way to start using Playwright is by creating a brand-new project.
Run the following command:
npm init playwright@latestThis is the official project initialization command recommended by the Playwright team.
During setup, Playwright asks a few interactive questions, such as:
- Which language do you want to use (JavaScript or TypeScript)?
- Where should your tests be stored?
- Do you want to install Playwright browsers?
- Do you want to create a GitHub Actions workflow?
After answering these questions, Playwright automatically creates a complete testing project.
What Does This Command Create?
Running npm init playwright@latest automatically performs several tasks for you.
1. Creates a Playwright Project Structure
A new project is generated with recommended folders and configuration files.
Example:
playwright-project/
│
├── tests/
│ └── example.spec.ts
│
├── playwright.config.ts
├── package.json
├── package-lock.json
└── node_modules/This structure follows Playwright best practices and gives you a clean starting point for building your automation framework.
2. Installs the Playwright Test Runner
The command automatically installs:
@playwright/testThis package includes:
- Playwright API
- Test Runner
- Assertions
- Fixtures
- Parallel execution support
- Built-in reporters
- Trace Viewer integration
There is no need to install additional testing libraries such as Mocha or Jest.
3. Creates playwright.config.ts
One of the most important files generated is playwright.config.ts. This configuration file controls nearly every aspect of your automation framework, including:
- Browser projects
- Base URL
- Timeouts
- Retries
- Parallel execution
- Workers
- Reporters
- Screenshots
- Video recording
- Tracing
As your framework grows, this file becomes the central place for configuring test execution.
4. Generates Example Tests
Playwright creates sample test files to help you get started immediately.
import { test, expect } from '@playwright/test';
test('has title', async ({ page }) => {
await page.goto('https://playwright.dev');
await expect(page).toHaveTitle(/Playwright/);
});These examples demonstrate Playwright's syntax and provide a quick way to verify that your installation is working correctly.
5. Downloads Browser Binaries
Unlike Selenium, Playwright manages browser binaries automatically.
During project creation, it downloads supported browsers, allowing your tests to run without requiring separate browser driver installations.
Supported browsers include:
- Chromium
- Firefox
- WebKit
This simplifies setup and ensures browser compatibility.
6. Optionally Creates a GitHub Actions Workflow
If you choose Yes during project creation, Playwright generates a ready-to-use GitHub Actions workflow.
This workflow enables automated test execution whenever code is pushed or a pull request is created, making it easy to integrate Playwright into a CI/CD pipeline from day one.
Install Playwright in an Existing Project
Sometimes you already have a Node.js application and simply want to add Playwright.
npm install -D @playwright/testThe -D flag installs Playwright as a development dependency because it is only required during testing and development.
This command is ideal when:
- Adding UI automation to an existing application
- Migrating from Selenium or Cypress
- Integrating Playwright into an existing repository
- Building an enterprise automation framework alongside production code
After installing the package, you'll typically create a Playwright configuration file and install the required browsers.
Install All Supported Browsers
Once Playwright is installed, download every supported browser using:
npx playwright installThis command installs all officially supported browser engines.
The downloaded browsers include:
- Chromium
- Firefox
- WebKit
Using Playwright-managed browsers ensures your tests run against known, compatible browser versions regardless of what is installed on the local machine.
This command is commonly used after cloning a repository for the first time or preparing a new CI environment.
Install a Specific Browser
If you only need one browser, Playwright lets you install it individually.
Install Chromium:
npx playwright install chromiumInstall Firefox:
npx playwright install firefoxInstall WebKit:
npx playwright install webkitInstalling only the browsers you need can reduce download size and speed up environment setup, especially in containerized or cloud-based environments.
For example:
- Chromium for Chrome and Microsoft Edge testing
- Firefox for Mozilla Firefox compatibility
- WebKit for Safari compatibility
Install Browser Dependencies
On Linux servers and many CI/CD environments, browsers require additional operating system libraries to run.
npx playwright install-depsThis command installs the necessary system packages required by Playwright browsers.
Typical environments include:
- Ubuntu
- Debian
- Docker containers
- GitHub Actions runners
- Jenkins Linux agents
- Azure DevOps Linux pipelines
Without these dependencies, browser launch failures are common.
Install Browsers and Dependencies Together
For Linux environments, Playwright provides a convenient command that installs both browser binaries and the required system libraries.
npx playwright install --with-depsThis combines two steps into one:
- Downloads Playwright browsers
- Installs operating system dependencies
This command is highly recommended for Docker images and fresh CI/CD build agents because it reduces setup time and prevents missing dependency issues.
Display the Installed Playwright Version
To verify which version of Playwright is installed, run:
npx playwright --versionExample output:
Version 1.56.0Checking the installed version is useful when:
- Verifying successful installation
- Troubleshooting compatibility issues
- Reporting bugs
- Ensuring consistency across development and CI environments
Many enterprise teams standardize on a specific Playwright version to avoid unexpected behavior caused by version differences.
Display Available CLI Commands
Playwright includes an extensive command-line interface.
npx playwright --helpThis displays the latest supported commands, options, and descriptions directly from the installed version of Playwright.
Example categories include:
- Installation commands
- Browser management
- Code generation
- Test execution
- Reporting
- Debugging
- Trace Viewer
- Screenshot utilities
Because the CLI evolves over time, using --help is the best way to explore new capabilities introduced in recent releases.
The official Playwright documentation also recommends this command as the authoritative source for the current CLI options available in your installed version.
Common Installation Workflow
For a brand-new project, a typical setup looks like this:
npm init playwright@latestAfter the interactive setup completes, verify your installation:
npx playwright --versionView available commands:
npx playwright --helpYour project is now ready for writing and executing Playwright tests.
Installation Workflow for Existing Projects
If you're integrating Playwright into an existing application, the process is slightly different.
First, install the Playwright test package:
npm install -D @playwright/testNext, download the required browsers:
npx playwright installFinally, verify that everything has been installed correctly:
npx playwright --versionThis workflow is common in enterprise environments where automation is added to an already established codebase.
Best Practices for Installing Playwright
Professional automation teams typically follow these recommendations:
- Use npm init playwright@latest when starting a new project.
- Install Playwright as a development dependency in existing applications.
- Download only the browsers required for your testing strategy when disk space or setup time matters.
- Use npx playwright install --with-deps on Linux, Docker, and CI servers to avoid missing system libraries.
- Verify the installed version after setup to ensure consistency across environments.
- Use npx playwright --help whenever you want to explore new CLI features or confirm the latest command options.
- Commit your playwright.config.ts file to version control so every team member shares the same configuration.
- Keep Playwright updated periodically, but validate framework compatibility before upgrading in production automation projects.
Final Thoughts
Playwright makes installation remarkably simple while providing the flexibility needed for professional automation projects. Whether you're creating a brand-new framework, adding Playwright to an existing application, preparing Docker containers, or configuring enterprise CI/CD pipelines, the Playwright CLI offers commands for every stage of the setup process.
By mastering these installation commands, you'll be able to build automation environments faster, onboard new team members more easily, and ensure your projects remain consistent across local development machines and build servers. As your Playwright framework grows, these foundational commands will become part of your daily workflow, making installation, maintenance, and troubleshooting far more efficient.
With a properly installed environment, you're now ready to move on to writing tests, organizing page objects, configuring browsers, and building a scalable Playwright automation framework that can support both small projects and large enterprise applications.
Get Playwright tutorials in your inbox
Weekly tips, real-world examples, and framework patterns – no spam, unsubscribe anytime.
Playwright Framework Series
View all →- 1Getting Started with Playwright: Installation, Setup, and Your First Test
- 2Playwright Locators: The Complete Guide with Real-World Examples
- 3Playwright Actions: Complete Guide to Click, Fill, Hover, Keyboard, Mouse & File Upload
- 4Playwright Assertions: The Complete Guide with Real-World Examples
- 5Playwright Auto Waiting: The Complete Guide with Real-World Examples
- 6Playwright Fixtures: The Complete Guide with Real-World Examples
- 7Playwright Browser Context & Multiple Tabs: The Complete Guide with Real-World Examples
- 8Playwright Authentication & Session Management: Complete Guide with Enterprise Examples
- 9Playwright Network Interception & API Mocking: Complete Guide with Real-World Examples
- 10Playwright Page Object Model (POM): The Complete Guide with Enterprise Examples
- 11Page Object Model with Playwright: A Practical Guide
- 12How to Build a Robust Professional Playwright Framework from Scratch (Step-by-Step)
- 13Building an Enterprise Playwright Framework from Scratch
API Testing Series
View all →- 1Playwright API Testing: The Complete Guide with Real-World Examples
- 2Part 1 : Playwright API Testing Tutorial: Build Enterprise-Level API Automation Framework
- 3Part 2: Playwright API Testing Tutorial: Setting Up Project & Sending Your First API Request
- 4Part 3: Mastering CRUD Operations in Playwright API Testing
- 5Part 4: Authentication in Playwright API Testing (Bearer Token, JWT, API Key & Reusable Fixtures)
- 6Part 5: Building an Enterprise-Level Playwright API Automation Framework
- 7Part 6: API Models, Schema Validation & Test Data Management in Playwright
- 8Part 7: Custom Fixtures, Hooks, Logging & Parallel Execution in Playwright API Testing
- 9Part 8: Building a Production-Ready Playwright API Framework (Environment Management, CI/CD, Reporting & Best Practices)
- 10Part 9: Advanced Playwright API Testing Techniques for Enterprise Automation
- 11Part 10: Building a Complete Enterprise Playwright API Automation Framework (Final Part)
- 12API Testing with Playwright: Request Context, Auth, and Assertions