Specnote
Back to the blog
how to use playwrightPlaywrighthow-toE2E testingSpecnote

How to use Playwright — from install to your first test run

By WonyoungAugust 21, 20264 min
On this page

If you follow this from the top, learning how to use Playwright takes about 10 minutes from install to first test run. One command installs it, an example test comes with it, and one command runs it. This post walks that 10 minutes in order, and then covers what is still left once you get there.

Key takeaways

How to use Playwright starts with a single install command that also sets up an example test and browsers. The installer asks four things: language, test folder, CI workflow and whether to download browsers. Getting to the first run takes about 10 minutes. Everything after that is the actual work.

How to use Playwright — what you need first

Node.js. That is the whole list. Browsers come down during install.

You do not need an app to test yet either. The installer writes an example test that runs against the Playwright site, so you can run it as-is.

How to use Playwright — the four steps from install to first runInstall, configure, run, review — four steps to your first Playwright run

How to install Playwright

From your project folder:

npm init playwright@latest

For other package managers, yarn create playwright and pnpm create playwright.

Per the official documentation, the installer asks four questions.

QuestionDefaultHow to decide
TypeScript or JavaScriptTypeScriptTake the default if unsure
Test folder nametestsUse e2e if tests already exists
Add a GitHub Actions workflowRecommendedYes, if you want tests running on every push later
Install browsers nowYesSay yes. This pulls Chromium, Firefox and WebKit

The browser download is the slow part. It is a sizeable payload the first time.

What gets created

When it finishes, the layout looks like this.

After installation
playwright.config.ts    configuration
package.json
tests/
  example.spec.ts       example test

playwright.config.ts holds which browsers to run, whether to retry on failure, whether to record traces. You do not need to touch it at first.

tests/example.spec.ts is the example. Reading that one file tells you most of what a test looks like.

What the Playwright installer createsThe installer writes a config file, an example test and optionally a CI workflow

Running your first test

One command.

npx playwright test

A browser opens without a visible window, the example runs, and the terminal reports pass or fail. The default config runs against Chromium, Firefox and WebKit, so two written tests show up as six results.

To watch it happen:

npx playwright test --headed

Run it headed once at the start. Seeing how a test drives the page makes the code much easier to read afterward.

Reading the results

When terminal output is not enough:

npx playwright show-report

A report opens in the browser with pass, fail and duration per test. Click a failure and you can see where it stopped.

Keep readingWhat is Playwright trace viewer? What is left when a test failsplaywright trace viewerPlaywright5 min

Pointing it at your own app

Once the example makes sense, swap in your own screen. A test looks roughly like this.

tests/login.spec.ts
import { test, expect } from '@playwright/test';

test('signing in lands on the dashboard', async ({ page }) => {
  await page.goto('http://localhost:3000/login');

  await page.getByLabel('Email').fill('me@example.com');
  await page.getByLabel('Password').fill('password');
  await page.getByRole('button', { name: 'Sign in' }).click();

  await expect(page.getByRole('heading', { name: 'Dashboard' })).toBeVisible();
});

It reads as the same sequence a person would follow. Open the page, fill the fields, click the button, confirm the expected screen appeared.

getByLabel and getByRole are how the test points at elements. Which of those you choose determines how long the test survives.

Keep readingWhat are Playwright locators? Writing tests that survive a redesignplaywright locatorsPlaywright6 min

If writing them by hand is slow, you can have your clicks recorded into code instead. The codegen post covers that route.

npx playwright codegen http://localhost:3000

What is left once you get here

Install and first run take 10 minutes. The rest does not.

First, deciding what to test. A tool checks only what you told it to. In a product with 20 screens, which flows matter and where the bar for "passing" sits is yours to set.

Second, updating tests as the UI changes. Change a feature and the test changes with it, and that work keeps coming back.

Third, deciding when they run. Anything triggered by hand gets forgotten. They have to run on every deploy to mean anything.

All three need someone who can read and edit code. Learning how to use Playwright and keeping a suite alive are different jobs.

Specnote takes the part after that

If you can read and edit code, writing tests directly in Playwright is more precise and more flexible. Start with the steps above.

Specnote is for the case where nobody has the time or the person for that work. AI lists what it built, you review and approve the list, and only the approved scope runs in a real browser. Nothing to install, no code to write.


Commands and setup steps in this post were verified against the Playwright installation docs on August 21, 2026.

Frequently asked questions

  • What do I need to install Playwright?

    Node.js. npm init playwright@latest sets up the config, an example test and the browsers. The browser step pulls Chromium, Firefox and WebKit.

  • I wrote two tests but got six results.

    The default config runs each test on three browsers. Remove the ones you do not want from the config, or pass --project=chromium when running.

  • Why does no browser window appear?

    Headless is the default. Add --headed to watch it run.

  • How do I test my own app instead of the example?

    Change the URL in the test file and write out the sequence you want checked. Put a baseURL in the config so you do not repeat it in every test.

  • Once I know how to use Playwright, is test automation done?

    It is the beginning. Deciding what to check, updating tests as the UI moves, and running them on every deploy are all still ahead, and they take longer than the install did. > [!CTA] > Check your app before installing anything > > Approve what should be checked from a list, and we run that scope in a real browser. No code to write. > > Start free

Keep reading

If you enjoyed this post