Windows automation guide
How to Set Up Playwright on Windows
A practical, step-by-step path from installing Node.js to running your first cross-browser automated test.
Introduction
Playwright is a modern end-to-end testing and browser automation framework built by Microsoft. It supports Chromium, Firefox, and WebKit through a single API, making cross-browser testing faster and more reliable.
If you’re a QA engineer, developer, or automation enthusiast using Windows, this guide covers everything you need to get Playwright running—from installing prerequisites to executing your first automated test script.
Prerequisites
- A Windows 10 or Windows 11 machine
- Administrator access to install software
- A stable internet connection for browser binaries
- A code editor such as Visual Studio Code (recommended)
Step-by-step setup
1. Install Node.js
Playwright runs on Node.js. Visit nodejs.org, download the Windows LTS release, and run the .msi installer with the default options.
Verify the installation in Command Prompt or PowerShell:
node -v
npm -vIf both commands return version numbers, Node.js and npm are ready.
2. Install Visual Studio Code
VS Code is optional, but its Playwright Test extension provides convenient test running and debugging. Download it from code.visualstudio.com, then install the Playwright Test for VSCode extension from the Extensions Marketplace.
3. Create a project folder
mkdir playwright-demo
cd playwright-demo4. Initialize a Node.js project
npm init -yThis creates a package.json file for managing project dependencies.
5. Install Playwright
npm init playwright@latestChoose your preferences when prompted:
- Language: TypeScript is recommended, though JavaScript is supported.
- Test folder: The default
testsfolder is a good choice. - GitHub Actions: Optional, and useful for CI/CD.
- Browsers: Choose Yes to download them now.
The generated project will look like this:
playwright-demo/
├── tests/
│ └── example.spec.ts
├── playwright.config.ts
├── package.json
└── node_modules/6. Verify browser installation
If browsers were not installed automatically, or you want to reinstall them, run:
npx playwright installThis downloads the Chromium, Firefox, and WebKit binaries needed for multi-browser testing.
7. Run your first test
npx playwright testPlaywright runs the generated sample test in headless mode and prints the results in your terminal.
8. View the HTML report
npx playwright show-reportThe interactive report opens in your default browser and includes test steps, screenshots, traces, and execution timelines.
9. Run tests in headed mode
Watch browser actions in real time, or target one browser project:
npx playwright test --headed
npx playwright test --project=chromium10. Write a custom test
Create tests/sample.spec.ts:
import { test, expect } from '@playwright/test';
test('has title', async ({ page }) => {
await page.goto('https://playwright.dev/');
await expect(page).toHaveTitle(/Playwright/);
});Run the test with:
npx playwright test sample.spec.tsIf it passes, your Playwright environment is fully functional.
Common setup issues on Windows
Always check configuration changes and security-related commands against your organization’s IT policies.
Best practices after setup
- Update Playwright and browser binaries with
npm install -D @playwright/test@latest, followed bynpx playwright install. - Use the Trace Viewer with
npx playwright show-traceto debug failures. - Organize larger test suites using the Page Object Model (POM).
- Integrate with GitHub Actions, Jenkins, or Azure DevOps for CI/CD.
Conclusion
Once Node.js is installed, setting up Playwright on Windows takes only a few commands. You now have multi-browser support, rich reporting, and powerful debugging tools ready for your automation work.
Take your test automation further
Subscribe for more Playwright tutorials, best practices, and real-world automation strategies delivered to your inbox.
FAQs
npx playwright install when needed.npm install -D @playwright/test@latest, followed by npx playwright install.