PLAYWRIGHT UIBEGINNER

How to Install Playwright – Complete Installation Guide with Commands

Learn how to install Playwright from scratch using npm. Create a new Playwright project, install browsers, browser dependencies, verify installation, and understand every Playwright installation command with examples.

iff Solution Academy July 25, 2026 12 min read Updated July 25, 2026
Playwright Installation npm CLI Setup Browsers Dependencies Beginner

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:

bash
npm init playwright@latest

This 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:

text
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:

text
@playwright/test

This 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.

example.spec.ts
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.

bash
npm install -D @playwright/test

The -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:

bash
npx playwright install

This 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:

bash
npx playwright install chromium

Install Firefox:

bash
npx playwright install firefox

Install WebKit:

bash
npx playwright install webkit

Installing 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.

bash
npx playwright install-deps

This 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.

bash
npx playwright install --with-deps

This 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:

bash
npx playwright --version

Example output:

text
Version 1.56.0

Checking 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.

bash
npx playwright --help

This 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:

bash
npm init playwright@latest

After the interactive setup completes, verify your installation:

bash
npx playwright --version

View available commands:

bash
npx playwright --help

Your 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:

bash
npm install -D @playwright/test

Next, download the required browsers:

bash
npx playwright install

Finally, verify that everything has been installed correctly:

bash
npx playwright --version

This 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 →
  1. 1Getting Started with Playwright: Installation, Setup, and Your First Test
  2. 2Playwright Locators: The Complete Guide with Real-World Examples
  3. 3Playwright Actions: Complete Guide to Click, Fill, Hover, Keyboard, Mouse & File Upload
  4. 4Playwright Assertions: The Complete Guide with Real-World Examples
  5. 5Playwright Auto Waiting: The Complete Guide with Real-World Examples
  6. 6Playwright Fixtures: The Complete Guide with Real-World Examples
  7. 7Playwright Browser Context & Multiple Tabs: The Complete Guide with Real-World Examples
  8. 8Playwright Authentication & Session Management: Complete Guide with Enterprise Examples
  9. 9Playwright Network Interception & API Mocking: Complete Guide with Real-World Examples
  10. 10Playwright Page Object Model (POM): The Complete Guide with Enterprise Examples
  11. 11Page Object Model with Playwright: A Practical Guide
  12. 12How to Build a Robust Professional Playwright Framework from Scratch (Step-by-Step)
  13. 13Building an Enterprise Playwright Framework from Scratch

API Testing Series

View all →
  1. 1Playwright API Testing: The Complete Guide with Real-World Examples
  2. 2Part 1 : Playwright API Testing Tutorial: Build Enterprise-Level API Automation Framework
  3. 3Part 2: Playwright API Testing Tutorial: Setting Up Project & Sending Your First API Request
  4. 4Part 3: Mastering CRUD Operations in Playwright API Testing
  5. 5Part 4: Authentication in Playwright API Testing (Bearer Token, JWT, API Key & Reusable Fixtures)
  6. 6Part 5: Building an Enterprise-Level Playwright API Automation Framework
  7. 7Part 6: API Models, Schema Validation & Test Data Management in Playwright
  8. 8Part 7: Custom Fixtures, Hooks, Logging & Parallel Execution in Playwright API Testing
  9. 9Part 8: Building a Production-Ready Playwright API Framework (Environment Management, CI/CD, Reporting & Best Practices)
  10. 10Part 9: Advanced Playwright API Testing Techniques for Enterprise Automation
  11. 11Part 10: Building a Complete Enterprise Playwright API Automation Framework (Final Part)
  12. 12API Testing with Playwright: Request Context, Auth, and Assertions

Recommended Next Articles