Playwright Setup Guide
Get Playwright running locally so you can automate the pages on this site. Playwright officially supports five languages — pick yours, then pick your OS.
- ✅ A code editor (VS Code recommended)
- ✅ Language runtime for the tab you choose below
Installation
-
Install Node.js
Go to nodejs.org and download the Node.js 24 (LTS) Windows installer — it's the version highlighted by default on the download page.
node --version -
Install an IDE — VS Code
Download from code.visualstudio.com and run the installer. Then install the official Playwright Test for VSCode extension from the Extensions panel — it lets you run and debug tests right from the editor.
-
Scaffold a Playwright project
mkdir playwright-practice cd playwright-practice npm init playwright@latestWhen prompted "TypeScript or JavaScript?", choose TypeScript. This also downloads the Chromium/Firefox/WebKit browser binaries automatically — no separate driver to install.
-
Verify with a basic test
Replace
tests/example.spec.tswith:import { test, expect } from '@playwright/test'; test('loads example.com', async ({ page }) => { await page.goto('https://example.com'); await expect(page).toHaveTitle(/Example/); });Run it from the terminal, or click "Run Test" in VS Code if you installed the extension:
npx playwright test --headedA browser window should open, load example.com, and the terminal should report the test passed.
-
Install Node.js
Using Homebrew (or download the Node.js 24 (LTS) installer from nodejs.org instead):
brew install node@24node --version -
Install an IDE — VS Code
Download from code.visualstudio.com and install it. Then install the official Playwright Test for VSCode extension from the Extensions panel — it lets you run and debug tests right from the editor.
-
Scaffold a Playwright project
mkdir playwright-practice cd playwright-practice npm init playwright@latestWhen prompted "TypeScript or JavaScript?", choose TypeScript. This also downloads the Chromium/Firefox/WebKit browser binaries automatically — no separate driver to install.
-
Verify with a basic test
Replace
tests/example.spec.tswith:import { test, expect } from '@playwright/test'; test('loads example.com', async ({ page }) => { await page.goto('https://example.com'); await expect(page).toHaveTitle(/Example/); });Run it from the terminal, or click "Run Test" in VS Code if you installed the extension:
npx playwright test --headedA browser window should open, load example.com, and the terminal should report the test passed.
-
Install Node.js
Go to nodejs.org and download the Node.js 24 (LTS) Windows installer — it's the version highlighted by default on the download page.
node --version -
Install an IDE — VS Code
Download from code.visualstudio.com and run the installer. Then install the official Playwright Test for VSCode extension from the Extensions panel — it lets you run and debug tests right from the editor.
-
Scaffold a Playwright project
mkdir playwright-practice cd playwright-practice npm init playwright@latestWhen prompted "TypeScript or JavaScript?", choose JavaScript. This also downloads the Chromium/Firefox/WebKit browser binaries automatically — no separate driver to install.
-
Verify with a basic test
Replace
tests/example.spec.jswith:const { test, expect } = require('@playwright/test'); test('loads example.com', async ({ page }) => { await page.goto('https://example.com'); await expect(page).toHaveTitle(/Example/); });Run it from the terminal, or click "Run Test" in VS Code if you installed the extension:
npx playwright test --headedA browser window should open, load example.com, and the terminal should report the test passed.
-
Install Node.js
Using Homebrew (or download the Node.js 24 (LTS) installer from nodejs.org instead):
brew install node@24node --version -
Install an IDE — VS Code
Download from code.visualstudio.com and install it. Then install the official Playwright Test for VSCode extension from the Extensions panel — it lets you run and debug tests right from the editor.
-
Scaffold a Playwright project
mkdir playwright-practice cd playwright-practice npm init playwright@latestWhen prompted "TypeScript or JavaScript?", choose JavaScript. This also downloads the Chromium/Firefox/WebKit browser binaries automatically — no separate driver to install.
-
Verify with a basic test
Replace
tests/example.spec.jswith:const { test, expect } = require('@playwright/test'); test('loads example.com', async ({ page }) => { await page.goto('https://example.com'); await expect(page).toHaveTitle(/Example/); });Run it from the terminal, or click "Run Test" in VS Code if you installed the extension:
npx playwright test --headedA browser window should open, load example.com, and the terminal should report the test passed.
-
Install Python
Go to python.org/downloads and download the latest Python 3 Windows installer. Run it, and check "Add python.exe to PATH" on the first screen.
python --version -
Install an IDE — PyCharm or VS Code
Either works fine for the rest of this guide. Pick one:
PyCharm: download the free Community edition from jetbrains.com/pycharm/download.
VS Code: download from code.visualstudio.com, then install the Python extension.
-
Create a project and install Playwright
mkdir playwright-practice cd playwright-practice python -m venv venv venv\Scripts\activate pip install pytest-playwright playwright installplaywright installdownloads the Chromium/Firefox/WebKit browser binaries — no separate driver to manage. -
Verify with a basic test
Save as
test_example.py:from playwright.sync_api import Page, expect def test_loads_example(page: Page): page.goto("https://example.com") expect(page).to_have_title("Example Domain")pytest test_example.py --headedA browser window should open, load example.com, and pytest should report 1 passed.
-
Install Python
Using Homebrew (or download the macOS installer from python.org/downloads instead):
brew install pythonpython3 --version -
Install an IDE — PyCharm or VS Code
Either works fine for the rest of this guide. Pick one:
PyCharm: download the free Community edition from jetbrains.com/pycharm/download (pick the Apple Silicon build if you're on an M-series Mac).
VS Code: download from code.visualstudio.com, then install the Python extension.
-
Create a project and install Playwright
mkdir playwright-practice cd playwright-practice python3 -m venv venv source venv/bin/activate pip install pytest-playwright playwright installplaywright installdownloads the Chromium/Firefox/WebKit browser binaries — no separate driver to manage. -
Verify with a basic test
Save as
test_example.py:from playwright.sync_api import Page, expect def test_loads_example(page: Page): page.goto("https://example.com") expect(page).to_have_title("Example Domain")pytest test_example.py --headedA browser window should open, load example.com, and pytest should report 1 passed.
-
Install the JDK
Go to oracle.com/java/technologies/downloads and download the JDK 17 or higher (LTS) — Windows x64 Installer (the
.msi). Run it.java -version -
Install an IDE — Eclipse or IntelliJ
Either works fine for the rest of this guide. Pick one:
Eclipse: download the installer from eclipse.org/downloads and choose "Eclipse IDE for Enterprise Java and Web Developers".
IntelliJ IDEA: download the free Community edition from jetbrains.com/idea/download.
-
Install Maven
Download from maven.apache.org, unzip it, and add its
binfolder to PATH in system environment variables.mvn -version -
Create a project and add Playwright
In your IDE: File → New → Project → Maven, or from a terminal:
mvn archetype:generate -DgroupId=com.practice -DartifactId=playwright-practice -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false cd playwright-practiceAdd to
pom.xmlinside<dependencies>:<dependency> <groupId>com.microsoft.playwright</groupId> <artifactId>playwright</artifactId> <version>1.46.0</version> </dependency> -
Install the browser binaries
Unlike Selenium, there's no ChromeDriver to manage — Playwright downloads its own tested Chromium/Firefox/WebKit builds:
mvn compile mvn exec:java -e -Dexec.mainClass=com.microsoft.playwright.CLI -Dexec.args="install" -
Verify with a basic test
Open the project in your IDE and replace
App.javawith:import com.microsoft.playwright.*; public class App { public static void main(String[] args) { try (Playwright playwright = Playwright.create()) { Browser browser = playwright.chromium().launch(new BrowserType.LaunchOptions().setHeadless(false)); Page page = browser.newPage(); page.navigate("https://example.com"); System.out.println(page.title()); browser.close(); } } }Run it from your IDE (right-click the file → Run), or from a terminal:
mvn compile exec:java -Dexec.mainClass="com.practice.App"A browser window should open, load example.com, and the title should print to the console.
-
Install the JDK
Go to oracle.com/java/technologies/downloads and download the JDK 17 (LTS) macOS Installer — pick ARM64 for Apple Silicon or x64 for Intel. Run the
.dmg, then confirm:java -versionPrefer Homebrew?
brew install openjdk@17works too. -
Install an IDE — Eclipse or IntelliJ
Either works fine for the rest of this guide. Pick one:
Eclipse: download the installer (.dmg) from eclipse.org/downloads and choose "Eclipse IDE for Enterprise Java and Web Developers".
IntelliJ IDEA: download the free Community edition from jetbrains.com/idea/download (pick the Apple Silicon build if you're on an M-series Mac).
-
Install Maven
brew install mavenmvn -version -
Create a project and add Playwright
In your IDE: File → New → Project → Maven, or from a terminal:
mvn archetype:generate -DgroupId=com.practice -DartifactId=playwright-practice -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false cd playwright-practiceAdd to
pom.xmlinside<dependencies>:<dependency> <groupId>com.microsoft.playwright</groupId> <artifactId>playwright</artifactId> <version>1.46.0</version> </dependency> -
Install the browser binaries
Unlike Selenium, there's no ChromeDriver to manage — Playwright downloads its own tested Chromium/Firefox/WebKit builds:
mvn compile mvn exec:java -e -Dexec.mainClass=com.microsoft.playwright.CLI -Dexec.args="install" -
Verify with a basic test
Open the project in your IDE and replace
App.javawith:import com.microsoft.playwright.*; public class App { public static void main(String[] args) { try (Playwright playwright = Playwright.create()) { Browser browser = playwright.chromium().launch(new BrowserType.LaunchOptions().setHeadless(false)); Page page = browser.newPage(); page.navigate("https://example.com"); System.out.println(page.title()); browser.close(); } } }Run it from your IDE (right-click the file → Run), or from a terminal:
mvn compile exec:java -Dexec.mainClass="com.practice.App"A browser window should open, load example.com, and the title should print to the console.
-
Install the .NET SDK
Go to dotnet.microsoft.com/download and download the latest .NET SDK Windows installer. Run it.
dotnet --version -
Install an IDE — Visual Studio or VS Code
Either works fine for the rest of this guide. Pick one:
Visual Studio: download the free Community edition from visualstudio.microsoft.com/downloads and select the ".NET desktop development" workload during install.
VS Code: download from code.visualstudio.com, then install the C# Dev Kit extension.
-
Create a project and add Playwright
dotnet new nunit -n PlaywrightPractice cd PlaywrightPractice dotnet add package Microsoft.Playwright.NUnit dotnet build -
Install the browser binaries
Unlike Selenium, there's no ChromeDriver to manage — Playwright generates a PowerShell helper script during build that downloads its own browsers:
pwsh bin/Debug/net8.0/playwright.ps1 install -
Verify with a basic test
Replace the generated test file with:
using Microsoft.Playwright.NUnit; [TestFixture] public class ExampleTest : PageTest { [Test] public async Task LoadsExample() { await Page.GotoAsync("https://example.com"); await Expect(Page).ToHaveTitleAsync("Example Domain"); } }Run it from your IDE, or from a terminal:
dotnet testThis runs headless by default —
dotnet testshould report the test passed in the terminal, that's a working setup.
-
Install the .NET SDK
Using Homebrew (or download the macOS installer from dotnet.microsoft.com/download instead):
brew install --cask dotnet-sdkdotnet --version -
Install an IDE
VS Code is the standard free choice on Mac (Visual Studio for Mac was discontinued). Download from code.visualstudio.com and install the C# Dev Kit extension.
Prefer a full IDE? JetBrains Rider (paid, free trial) from jetbrains.com/rider/download also works well.
-
Create a project and add Playwright
dotnet new nunit -n PlaywrightPractice cd PlaywrightPractice dotnet add package Microsoft.Playwright.NUnit dotnet build -
Install the browser binaries
Unlike Selenium, there's no ChromeDriver to manage — Playwright generates a shell helper script during build that downloads its own browsers:
pwsh bin/Debug/net8.0/playwright.sh installNo
pwsh? Install PowerShell first:brew install --cask powershell -
Verify with a basic test
Replace the generated test file with:
using Microsoft.Playwright.NUnit; [TestFixture] public class ExampleTest : PageTest { [Test] public async Task LoadsExample() { await Page.GotoAsync("https://example.com"); await Expect(Page).ToHaveTitleAsync("Example Domain"); } }Run it from your IDE, or from a terminal:
dotnet testThis runs headless by default —
dotnet testshould report the test passed in the terminal, that's a working setup.
page.goto() at any page, toggle Help (top right) to
reveal each element's locator icon, and copy the code straight into your test.