Next-Gen App & Browser
Testing Cloud

Trusted by 2 Mn+ QAs & Devs to accelerate their release cycles

Next-Gen App & Browser Testing Cloud
  • Automation
  • Home
  • /
  • Learning Hub
  • /
  • How to Install Playwright: A Comprehensive Guide for 2025

How to Install Playwright: A Comprehensive Guide for 2025

Learn how to install Playwright with this step-by-step guide. Covers setup, install commands, and troubleshooting tips to kickstart end-to-end testing.

Published on: September 3, 2025

  • Share:

Whether you're just starting with end-to-end testing or migrating from other automation testing tools, this step-by-step guide will help you install Playwright framework to get started.

Overview

Playwright is an open-source framework for fast, reliable end-to-end web testing across browsers, with support for multiple languages and advanced automation features.

How to Install Playwright Using Command Line

  • Initialize a Node.js project using npm init -y.
  • Install Playwright with npm install -D playwright
  • Install browser binaries using npx playwright install.
  • Run the tests using npx playwright test.

How to Install Playwright Using VS Code

  • Open VS Code and create a new project folder.
  • Open the terminal in VS Code and run npm init playwright@latest.
  • Follow the prompts to configure Playwright (choose language, browsers, etc.).
  • Install the suggested Playwright Test extension if prompted.
  • Write and run your tests directly from VS Code or use npx playwright test in the terminal.

What Is Playwright?

Playwright is an open-source browser automation framework built by Microsoft. It lets you write end-to-end tests for web applications using a single API that works across Chromium, Firefox, and WebKit. You can use Playwright with JavaScript, TypeScript, Python, Java, and .NET.

It has built-in reliability features like auto-wait, trace viewer, and browser context isolation. Playwright also supports headless and headed modes, parallel execution, and full CI/CD integration. This makes it a solid choice for developers and QA engineers working in fast-paced teams.

Prerequisites for Playwright Installation

Before installing Playwright, make sure you have a few things in place.

System Requirements:

  • Node.js version 18 or higher
  • npm (comes with Node.js)
  • Windows 10+, macOS 12+, or Ubuntu 20.04+
  • At least 2GB free disk space for browser binaries

Optional but helpful:

  • Visual Studio Code (for GUI-based setup and debugging)
  • Git (for version control and CI workflows)
  • Python/pip, Java/Maven, or .NET/NuGet if using those languages

Install Playwright via Command Line

This method is best if you're setting up Playwright from scratch or want full control over your environment.

Step 1: Initialize a new project by running the below command:


npm init playwright@latest

Or use:


yarn create playwright
# or
pnpm create playwright

You'll be prompted to choose a language (JavaScript or TypeScript), a test folder, and whether you want to install the recommended browsers and GitHub Actions config.

Once completed, you’ll get:

  • A Playwright config file
  • Sample tests
  • Installed browser binaries

Step 2: Run a sample test using the below command:

npx playwright test

This will execute the example test in headless mode. If you want to watch the browser in action:


npx playwright test --headed

Step 3: Use the interactive Test Runner to run tests, inspect traces, and debug failures using a visual interface.

npx playwright test --ui
Note

Note: Run Playwright tests across 50+ real desktop browsers . Try LambdaTest Today!

Install Playwright via VS Code

If you like a more hands-on, user-friendly setup, Visual Studio Code makes it really easy to install and manage Playwright.

Step 1: Install "Playwright Test for VSCode" from Microsoft via the Extensions tab.Playwright install button on VS Code

Step 2: Open an empty folder in VS Code. Then open the command palette (Ctrl+Shift+P or Cmd+Shift+P) and search for “Install Playwright.”Install Playwright command

The extension will prompt you to:

  • Choose browsers (Chromium, Firefox, WebKit)
  • Select JavaScript or TypeScript
  • Add sample tests and GitHub Actions setup
Install Playwright browsers

Step 3: You can now use Playwright to run tests or debug them directly from the sidebar using the green play and debug icons. The extension also supports Trace Viewer and test output logs.Play icon to run Playwright tests in VS code

You can also check out this video tutorial on setting up Playwright by Koushik Chatterjee. He is a Founder of LetCode and Senior Software Test Automation Engineer. Koushik brings close to 10 years of experience in test automation, specializing in building reliable frameworks and driving quality at scale.

Troubleshooting Common Playwright Installation Issues

Even with a straightforward setup process, you might encounter a few common hiccups.

Here are a few of the typical installation issues and how to resolve them.

  • PowerShell Execution Policy Error

    If you see this:

    npm : File cannot be loaded because running scripts is disabled

    Use the below command in PowerShell or run the command from Command Prompt instead:


    powershell -ExecutionPolicy Bypass -Command "npm init playwright@latest"
  • Node or npm Not Recognized

    Check Node.js installation using the below command:

    node -v
    npm -v

    Ensure system PATH is correctly set. Restart your terminal if needed.

  • Browsers Not Installed

    Install browser binaries using the below command:

    npx playwright install
  • npx Playwright Install Not Found

    Ensure Playwright is installed locally in your project. Avoid using global installations with npx.

  • Unable to Verify the First Certificate

    This may occur in corporate environments with strict SSL/TLS policies. Set the NODE_TLS_REJECT_UNAUTHORIZED environment variable to 0 temporarily:

      export NODE_TLS_REJECT_UNAUTHORIZED=0
  • Command Not Found

    Ensure that the playwright command is available in your PATH. Reinstall Playwright if necessary.

  • Errors in CI Environments

    On Vercel or Netlify, install only required browsers:

    npx playwright install chromium

    Set browser path to persist across builds if needed.

Post Playwright Installation Configuration

Once Playwright is installed, a few configuration steps can help you tailor it to your project’s needs.

  • Update Playwright

    Update Playwright using the below command:


    npm install -D @playwright/test@latest
    npx playwright install
  • Modify Your Config

    Edit playwright.config.ts or playwright.config.js file:

    • Set browsers
    • Configure test retries and timeouts
    • Choose reporter formats (HTML, JSON, JUnit)
    • Enable screenshots or videos on failure
  • Customize Test Structure

    Organize tests into folders, use tags, and set environment-specific configs with project overrides.

Conclusion

Installing Playwright is a straightforward process that can be accomplished via command line or Visual Studio Code. By following this guide, you can set up Playwright in your development environment and begin automating browser tasks efficiently.

By default, Playwright runs tests locally, which works well for quick feedback during development. But if you need to test across different browser versions, operating systems, or parallel sessions, integrating with a cloud-based platform like LambdaTest to streamline cross-browser execution. It is an AI testing platform that lets you run automated tests on its Playwright automation cloud across 50+ browsers and operating systems combinations.

To get started, check out this guide on Playwright testing with LambdaTest.

...

Citations

Frequently Asked Questions (FAQs)

How do I install Playwright?
You can install Playwright using npm by running `npm install -D @playwright/test` in your terminal. This installs the Playwright Test runner along with its dependencies.
How do I install Playwright browsers?
After installing the Playwright package, run `npx playwright install` to download the browser binaries for Chromium, Firefox, and WebKit.
Can I install Playwright with a specific browser only?
Yes. You can run `npx playwright install chromium`, `npx playwright install firefox`, or `npx playwright install webkit` to install only the required browser.
Is Playwright available via pip for Python users?
Yes. Python users can install Playwright using `pip install playwright`, and then run `playwright install` to fetch the browser binaries.
What are the system requirements for installing Playwright?
Playwright requires Node.js version 14 or later for JavaScript/TypeScript, and Python 3.7+ for Python environments. The system must support downloading and executing browser binaries.
Can Playwright be installed offline?
Playwright needs internet access to download browser binaries during the initial setup. However, for offline or CI environments, you can cache and reuse downloaded binaries using environment variables or custom paths.
Where is Playwright installed in Windows?
Playwright’s core package is installed in the project’s `node_modules` folder. Browser binaries are stored in `%USERPROFILE%\AppData\Local\ms-playwright` by default.
How do I install Playwright in VS Code?
In VS Code, open the terminal, run `npm init -y` to create a project, then run `npm install -D @playwright/test` and `npx playwright install`. You can also install the Playwright Test VS Code extension for test integration.
Do I need to install Playwright browsers separately?
Yes. After installing the Playwright package, you must run `npx playwright install` to download the browser binaries needed for running tests.

Did you find this page helpful?

Helpful

NotHelpful

More Related Hubs

ShadowLT Logo

Start your journey with LambdaTest

Get 100 minutes of automation test minutes FREE!!

Signup for free