How to Install Playwright in 2026: Complete Beginner Setup Guide


If you are starting your journey in automation testing, one of the first questions you may have is:
How do I install Playwright on my computer?

The good news is that you do not need a complicated setup. Once Node.js is ready, Playwright can create most of the project structure for you.

In this guide, we will build a small Playwright environment from the ground up. You will learn what needs to be installed, how to create a project, how Playwright prepares browsers, how to run a test, and what to do when something goes wrong.

The examples are written for beginners, so you can follow them even if automation testing is completely new to you.


What Do You Need to Start?

Before creating a Playwright project, your computer needs a few basic things.

1. Node.js

Node.js provides the environment required to run JavaScript or TypeScript applications from your computer's terminal.

Playwright's Node.js workflow uses npm to install packages and manage your project.

After installing Node.js, open Command Prompt, PowerShell, Windows Terminal, or the terminal inside VS Code.

Type:

node -v


You should see a version number.

Now check npm:

npm -v


If both commands return version numbers, your Node.js environment is ready.

If your computer says that the command is not recognized, finish the Node.js installation first and open a new terminal window.


Create a Separate Workspace for Playwright

It is better to keep automation projects separate from other files.

For example, create a folder called:

playwright-practice


Open your terminal inside that location or navigate to it with:

cd playwright-practice


You can choose any folder name you like.

The important idea is simple: one project should have its own working space.

This makes your test files, configuration, reports, and installed packages easier to manage later.


Create Your Playwright Project

Now we can let Playwright create the initial project.

Run:

npm init playwright@latest


This command starts the Playwright project setup process.

Instead of manually creating every file, the initializer asks you a few questions and prepares the project based on your choices.

You may be asked about:

  • The programming language

  • The location of your test files

  • Whether a GitHub Actions workflow should be added

  • Whether Playwright browsers should be installed

If you are learning web automation and already understand basic JavaScript, JavaScript can be a simple starting point. TypeScript is another popular choice, especially for larger automation projects.

Do not worry if the questions look slightly different in a newer Playwright release. Installation screens and defaults can change between versions.


Why Does Playwright Need Browser Installation?

Installing the Playwright package is only one part of the setup.

Your automated test needs a browser to interact with.

Playwright can automate browser engines including:

  • Chromium

  • Firefox

  • WebKit

During project creation, Playwright can download the browser binaries required by your setup.

If you skipped browser installation or need to install them later, run:

npx playwright install


You can also install a particular browser when your project requires it.

For example:

npx playwright install chromium


Think of it this way:

Playwright is the driver, while the browser is the environment where your test performs its actions.

Both pieces need to be available for browser automation.


Explore the Project Playwright Created

After the setup finishes, open the project in VS Code.

If the code command works on your computer, you can use:

code .


Otherwise, launch VS Code normally and open the project folder.

You will normally find files and folders similar to these:

playwright-practice/

│

├── tests/

│   └── example.spec.ts

│

├── playwright.config.ts

├── package.json

├── package-lock.json

└── node_modules/


The exact contents can vary depending on your choices and Playwright version.

Here is what the main parts mean.

tests

This is where your automated test files can live.

For example:

login.spec.ts

search.spec.ts

checkout.spec.ts


package.json

This file describes the Node.js project and its dependencies.

It also contains useful scripts and package information.

node_modules

This directory contains installed npm packages used by the project.

You normally do not edit these files manually.

playwright.config.ts

This is the central configuration file for many Playwright projects.

It can control settings such as browsers, test directories, retries, reporters, timeouts, and other execution options.


Your First Playwright Test

Now let's create a very small test.

Create a file such as:

homepage.spec.ts


Inside it, you can write:

import { test, expect } from '@playwright/test';


test('homepage opens correctly', async ({ page }) => {

  await page.goto('https://playwright.dev/');

  await expect(page).toHaveTitle(/Playwright/);

});


What is happening here?

test creates the automated test.

page represents the browser tab that Playwright controls.

page.goto() tells the browser to visit a website.

expect() checks whether the result matches what we expect.

In this example, the test opens the Playwright website and checks its page title.

You have now moved from installing Playwright to actually using it.


Run Your Test

Open your terminal in the project directory and execute:

npx playwright test


Playwright will discover your test files and execute them.

If the test succeeds, the terminal will show a successful result.

If something fails, Playwright provides information that can help you investigate the problem.

You can also run one particular test file:

npx playwright test tests/homepage.spec.ts


Replace the filename with the actual location of your test.


Want to Watch the Browser?

By default, automated tests can run without displaying the browser window.

That is useful for fast execution, but beginners often want to watch what is happening.

Use:

npx playwright test --headed


Now the browser can be displayed while the test runs.

This is especially helpful when you are learning because you can visually connect your code with the browser actions.

For example:

page.goto()

       ↓

Website opens


locator()

       ↓

Element is found


click()

       ↓

Button is selected


expect()

       ↓

Result is checked


This simple mental model makes Playwright easier to understand.


Try Playwright UI Mode

Playwright also provides an interactive UI mode for working with tests.

Run:

npx playwright test --ui


The interface allows you to inspect and run tests in a more visual way.

For someone learning automation, this can be useful because you are not limited to reading terminal output.

You can experiment with tests, execute them again, and investigate results while developing your automation.


Generate Automation Code With Codegen

Another useful Playwright feature is Codegen.

Start it with:

npx playwright codegen


A browser window opens and Playwright can observe your interactions.

For example, you could open a website, select an element, enter information, or click a button.

Playwright can generate code representing those actions.

Codegen is useful for learning because it helps you understand how browser interactions can be expressed in Playwright.

However, do not treat generated code as automatically perfect.

Review the selectors and simplify the test when necessary. A good automation script should be readable, stable, and easy for another tester to maintain.


Where Are the Test Results?

When a test fails, Playwright may create files containing information about the execution.

Depending on your configuration and execution options, you may see directories containing test artifacts.

For example:

test-results/


These files can help you investigate failures.

Playwright can also produce an HTML report.

To open the report, use:

npx playwright show-report


A report is useful because it gives you a clearer view of which tests passed, which tests failed, and where you should investigate.


Common Installation Problems

Node.js Is Not Recognized

If this command fails:

node -v


your Node.js installation or PATH configuration may need attention.

Install or repair Node.js and then open a fresh terminal.


Browser Executable Is Missing

If Playwright reports that a browser executable is unavailable, try:

npx playwright install


This downloads the browser binaries required by Playwright.


Playwright Test Is Not Found

First make sure your terminal is inside the correct project directory.

Check whether the folder contains:

package.json

playwright.config.ts

tests/


Then run:

npx playwright test



The Browser Does Not Appear

A test can pass even when you do not see a browser window.

That is normal when the test is running in headless mode.

To see the browser:

npx playwright test --headed



What Should You Learn After Installation?

Installing Playwright is only your starting point.

A beginner-friendly learning sequence can look like this:

JavaScript/TypeScript basics → Playwright fundamentals → Locators → Actions → Assertions → Fixtures → Page Object Model → Authentication → API Testing → Debugging → Reports → CI/CD → Real-world projects

Do not try to learn every topic on the same day.

First understand how a test works.

Then learn how Playwright finds elements.

After that, practice assertions and reusable test structures.

Once your basics are comfortable, move toward framework design and real project automation.


Frequently Asked Questions

Is Playwright difficult to install?

For a basic Node.js project, the setup is straightforward. The Playwright project initializer handles much of the initial configuration.

What command creates a Playwright project?

Use:

npm init playwright@latest


Then follow the prompts provided by the installer.

Do I need Node.js?

For Playwright's JavaScript and TypeScript workflow, Node.js is required.

Does Playwright install browsers automatically?

During project setup, you can choose to install the required browsers. If they are not installed, you can run:

npx playwright install


Can a complete beginner learn Playwright?

Yes. You can begin with small tests, but learning basic JavaScript or TypeScript will make automation much easier.

How do I confirm that my installation works?

Create or use a test and run:

npx playwright test


A successful test run confirms that your project can discover and execute Playwright tests.


Final Checklist

Before you start writing larger automation projects, make sure you can do these things:

  • Install Node.js

  • Check Node.js and npm versions

  • Create a Playwright project

  • Install the required browsers

  • Open the project in VS Code

  • Understand the basic project files

  • Create a test

  • Run a test

  • Run tests in headed mode

  • Open Playwright UI mode

  • Generate sample code with Codegen

  • View test reports

  • Troubleshoot basic installation problems

Once these steps become familiar, you are ready to move beyond installation and start building real browser automation.

Don’t just memorize Playwright commands; learn what they do and how they help you build tests.  That understanding will help you much more when you begin working with locators, assertions, Page Object Model, API testing, authentication, and CI/CD.



 

Comments

Popular posts from this blog

How to Run Only Smoke Tests in Playwright: Step-by-Step Guide

How to Test REST APIs Using Playwright

Playwright Multiple Tabs and Windows Explained: A Practical Guide