Automation TestingMay 25, 2026· 2 days ago12 min read

Playwright Installation Guide for Beginners (Windows, Mac & Linux) — 2026

Step-by-step Playwright installation guide for beginners on Windows, Mac and Linux. Install Node.js, set up Playwright with npm, run your first test, fix common errors and learn best practices.

Share:XLinkedInWhatsApp
Playwright installation guide for beginners — step-by-step setup tutorial for Windows, Mac and Linux with Node.js, npm and your first Playwright test.
Playwright installation guide for beginners — step-by-step setup tutorial for Windows, Mac and Linux with Node.js, npm and your first Playwright test.

Modern web apps are fast, dynamic and JavaScript-heavy — traditional automation tools often struggle with flaky tests, sync issues and slow execution. Playwright solves all three. In this complete Playwright installation guide you'll go from a blank machine to a running test in under 15 minutes — on Windows, Mac or Linux.

By the end you'll know what Playwright is, why QA engineers prefer it, how to install and configure it, how to run your first test, and how to fix the most common installation errors. If you want the deeper API tour after setup, read our Playwright complete guide.

1. What Is Playwright?

Playwright is an open-source automation framework from Microsoft for web UI, end-to-end, cross-browser, API and mobile-browser testing. It drives Chromium, Firefox and WebKit from a single API, which means you can test Chrome, Edge, Firefox and Safari-like browsers with the same code. After install, jump into our Playwright complete guide for locators, fixtures and the Page Object Model.

2. Why QA Engineers Prefer Playwright

  • Auto-waiting for elements, navigation and network — far fewer flaky tests.
  • Cross-browser Chromium, Firefox and WebKit out of the box.
  • Fast execution with parallel workers and headless mode.
  • Built-in API testing (GET/POST/PUT/DELETE) — no extra libraries.
  • World-class debugging: Trace Viewer, screenshots, video, HTML reports.

3. Prerequisites Before Installing Playwright

You need Node.js, npm, a working internet connection, and ideally VS Code.

RequirementNeeded
Node.js (LTS)Yes
npmYes
VS CodeRecommended
Internet connectionYes

4. Install Node.js (Windows, Mac, Linux)

Download the LTS version from the official Node.js website.

  • Windows: run the .msi installer, accept defaults, finish.
  • Mac: run the .pkg installer (or brew install node).
  • Linux (Ubuntu/Debian): sudo apt update && sudo apt install nodejs npm.

Verify the install:

node -v   # e.g. v22.0.0
npm -v    # e.g. 10.5.1

5. Install Playwright Using npm

Create a project folder and initialise Playwright:

mkdir playwright-project
cd playwright-project
npm init -y
npm init playwright@latest

The interactive CLI asks a few questions — recommended answers:

  • TypeScript (better autocomplete & maintainability)
  • Install browsers: Yes (downloads Chromium, Firefox, WebKit)
  • GitHub Actions workflow: Yes (useful for CI/CD later)

If browsers don't install automatically, run:

npx playwright install

6. Project Structure Overview

playwright-project/
├── tests/                  # your test scripts (*.spec.ts)
├── playwright.config.ts    # main config
├── package.json
├── node_modules/
└── playwright-report/      # generated after a run

7. Run Your First Playwright Test

Execute the bundled sample suite:

npx playwright test

You should see something like 3 passed. Open the HTML report with:

npx playwright show-report

Now create your own test at tests/login.spec.ts:

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

test('Verify page title', async ({ page }) => {
  await page.goto('https://example.com');
  await expect(page).toHaveTitle(/Example/);
});

Run just this file: npx playwright test login.spec.ts.

8. Run Tests in Different Browsers & Modes

npx playwright test --project=chromium
npx playwright test --project=firefox
npx playwright test --project=webkit

# headed (see the browser)
npx playwright test --headed

# step-by-step debugger
npx playwright test --debug

Default is headless mode — fastest for CI. Use --debug for the Playwright Inspector with pause and locator inspection.

9. Configure Playwright Properly

Edit playwright.config.ts:

import { defineConfig } from '@playwright/test';

export default defineConfig({
  testDir: './tests',
  timeout: 30000,
  retries: 1,
  use: {
    headless: true,
    screenshot: 'only-on-failure',
    video: 'retain-on-failure',
  },
});
OptionPurpose
timeoutPer-test timeout
retriesRetry failed tests
screenshotCapture screenshots on failure
videoRecord execution
headlessRun without UI

10. VS Code Extension + Codegen

Install Visual Studio Code and the Playwright Test for VSCode extension — you'll get one-click run, visual debug, locator recording and code generation inside the editor.

Auto-generate test code by interacting with a real site:

npx playwright codegen https://example.com

Playwright records your clicks and types and emits a clean spec file — perfect for beginners.

11. Common Installation Errors & Fixes

  • node is not recognized — restart your terminal after installing Node.js, or reinstall and ensure Node.js is on your PATH.
  • Browser download failed — re-run npx playwright install.
  • Linux permission errorssudo chmod -R 777 playwright-project.
  • npm install failednpm cache clean --force then reinstall.
  • Dependency issues — delete node_modules and package-lock.json, then npm install.

12. Best Practices for Beginners

  1. Use TypeScript for autocomplete and maintainability.
  2. Keep tests independent — each test should set up and tear down its own state.
  3. Use the Page Object Model for reusable, scalable test code.
  4. Avoid hard waits like waitForTimeout(5000). Rely on auto-waiting and web-first assertions.
  5. Store test data & credentials separately — outside spec files, in env vars or fixtures.

13. Playwright Commands Cheat Sheet

CommandPurpose
npx playwright testRun all tests
npx playwright show-reportOpen HTML report
npx playwright test --headedRun with browser UI
npx playwright test --debugDebug tests
npx playwright codegenGenerate scripts
npx playwright installInstall browsers

14. What to Learn Next

Your environment is ready — now go deeper:

15. Final Thoughts

Playwright is fast, reliable and beginner-friendly — and now you have it installed and running. Keep practising daily, build a small real-world automation project, and your QA career will accelerate fast in 2026.

Frequently asked questions

Is Playwright better than Selenium?

For modern web apps, yes — Playwright is faster, auto-waits, ships fixtures, tracing and parallelism out of the box. Selenium still leads in legacy enterprise ecosystems and Appium-based mobile testing.

Does Playwright support API testing?

Yes. Playwright supports REST API testing, request validation and response assertions natively, no extra libraries required.

Can beginners learn Playwright easily?

Yes. Cleaner syntax, excellent documentation and auto-waiting make Playwright one of the most beginner-friendly automation frameworks.

Which language is best for Playwright?

TypeScript and JavaScript are most popular. Playwright also officially supports Python, Java and .NET/C#.

Is Playwright free?

Yes — Playwright is fully open-source under the Apache 2.0 license and maintained by Microsoft.

How do I fix 'node is not recognized' on Windows?

Restart your terminal after installing Node.js. If it still fails, reinstall Node.js and make sure it is added to your system PATH during setup.

Ready to practice?

Run a free AI mock interview tailored to your domain.

Start free
Found this useful?
Share:XLinkedInWhatsApp

Continue reading

Join the QA community

Connect with fellow testers, share job leads, and get career advice.