Automation Testing · Playwright Start Guide
Playwright for Beginners: Where to Start in 2026
Quick summary — playwright for beginners
For Playwright beginners, start in this order: install Node.js and run npm init playwright@latest, write and run one simple test, learn role-based locators and web-first assertions so tests are stable, then use the config file and a CI workflow to run tests automatically. Aim for ten clean tests in your first month rather than learning every feature.
In this guide you will learn:
- Installation and your first test — the first hour.
- Locators and assertions — the two skills that matter most.
- Config, reports and CI — running tests like a team.
- A 30-day plan — daily tasks and checkpoints.
- Tips — beginner mistakes to avoid.
SECTION 01Installation and your first test
Playwright's setup command creates everything you need: a config file, an example test and browser downloads. Your first goal is simply to see a test pass, so you know the setup works before learning more.
| Step | Command or action | What it does | Check |
|---|---|---|---|
| Install Node.js | Download the LTS version from nodejs.org | Provides npm | node -v prints a version |
| Create the project | npm init playwright@latest | Adds config, tests folder, browsers | Folder has playwright.config.ts |
| Run tests | npx playwright test | Runs example tests in browsers | All tests pass |
| Open the report | npx playwright show-report | HTML report in your browser | Report lists tests |
node -v # check Node.js is installed
mkdir my-playwright && cd my-playwright
npm init playwright@latest # choose TypeScript, tests folder
npx playwright test
npx playwright show-report
// tests/first.spec.ts
import { test, expect } from "@playwright/test";
test("Playwright homepage has the right title", async ({ page }) => {
await page.goto("https://playwright.dev/");
await expect(page).toHaveTitle(/Playwright/);
});
test("Get started link opens the intro page", async ({ page }) => {
await page.goto("https://playwright.dev/");
await page.getByRole("link", { name: "Get started" }).click();
await expect(page.getByRole("heading", { name: "Installation" })).toBeVisible();
});
SECTION 02Locators and assertions: the two core skills
Most beginner problems come from fragile locators or wrong assertions. Learning Playwright's recommended locators and web-first assertions early saves weeks of flaky tests.
| Skill | Use | Example | Avoid |
|---|---|---|---|
| getByRole | Buttons, links, headings | getByRole('button', { name: 'Submit' }) | Long CSS chains |
| getByLabel / getByPlaceholder | Form fields | getByLabel('Email') | Index-based selectors |
| toBeVisible / toHaveText | Check what users see | expect(msg).toHaveText('Saved') | Manual waits before checks |
| toHaveURL / toHaveTitle | Check navigation | expect(page).toHaveURL(/dashboard/) | Reading URLs into variables |
import { test, expect } from "@playwright/test";
test("todo list adds two items", async ({ page }) => {
await page.goto("https://demo.playwright.dev/todomvc");
const input = page.getByPlaceholder("What needs to be done?");
await input.fill("Learn locators");
await input.press("Enter");
await input.fill("Learn assertions");
await input.press("Enter");
await expect(page.getByTestId("todo-item")).toHaveCount(2);
await expect(page.getByText("2 items left")).toBeVisible();
});
# Let Playwright suggest locators: open the inspector and hover elements
npx playwright codegen https://demo.playwright.dev/todomvc
# Or debug one test step by step:
npx playwright test tests/first.spec.ts --debug
SECTION 03Config, reports and CI
Once tests work locally, the config file controls browsers, base URL, retries and reports. Adding a CI workflow makes your tests run on every push — a big step towards working like a real team.
| Setting | Where | Example | Why |
|---|---|---|---|
| baseURL | use: in config | baseURL: 'https://demo.playwright.dev' | Shorter page.goto paths |
| Browsers | projects: in config | chromium, firefox, webkit | Cross-browser coverage |
| Retries | retries: in config | 2 on CI, 0 locally | Handle rare CI noise |
| Traces | use.trace | 'on-first-retry' | Debug failures easily |
import { defineConfig, devices } from "@playwright/test";
export default defineConfig({
testDir: "./tests",
retries: process.env.CI ? 2 : 0,
reporter: "html",
use: {
baseURL: "https://demo.playwright.dev",
trace: "on-first-retry",
},
projects: [
{ name: "chromium", use: { ...devices["Desktop Chrome"] } },
],
});
# .github/workflows/playwright.yml
name: playwright
on: [push]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: { node-version: 20 }
- run: npm ci
- run: npx playwright install --with-deps
- run: npx playwright test
SECTION 04A 30-day Playwright plan for beginners
Follow this plan for about 30 to 45 minutes a day. By day 30 you will have a small, clean test suite on GitHub. For a related walkthrough, see Selenium Skills for Automation Tester Jobs.
Days 1-10: setup and basics
Day 1 Install Node.js and Playwright, run examples
Day 2 Write first test with goto and toHaveTitle
Day 3 Learn getByRole and click
Day 4 Forms: fill, press, getByLabel
Day 5 Assertions: toBeVisible, toHaveText, toHaveCount
Day 6 Use codegen, then clean up its output
Day 7 Debug a test with --debug
Day 8-10 Write 5 tests for the TodoMVC demo
Days 11-20: structure and stability
Day 11 test.describe and test.beforeEach
Day 12 baseURL in config
Day 13 Remove any waitForTimeout from your tests
Day 14 Traces: run with --trace on and open one
Day 15 Simple page object for the todo page
Day 16-20 Write 5 more tests, keep each short and focused
Days 21-30: share and polish
Day 21 Push the project to GitHub
Day 22 Add the GitHub Actions workflow
Day 23 Add Firefox to projects
Day 24 Write a README: what, how to run, what you learned
Day 25 Add one API test with the request fixture
Day 26-30 Review, refactor names, fix any flaky test
SECTION 05Beginner mistakes to avoid
These mistakes slow down most Playwright beginners. Avoiding them keeps your first month productive and your tests trustworthy. You may also find Skills You Need to Become an Automation Tester and Playwright Skills for QA Tester Jobs useful.
- Using waitForTimeout — replace fixed waits with web-first assertions.
- Copying codegen blindly — clean names and add meaningful assertions.
- Long tests — one user goal per test keeps failures easy to understand.
- Fragile selectors — prefer roles, labels and test IDs over deep CSS paths.
- Learning everything at once — fixtures, sharding and mocking can wait until basics feel natural.
SECTION 06Interview Q&A — playwright for beginners
Q1How do you start a Playwright project?
Install Node.js, run npm init playwright@latest, then run npx playwright test to confirm the setup works.
Q2What is a web-first assertion?
An assertion like toBeVisible or toHaveText that automatically retries until the condition is met or times out.
Q3Why prefer getByRole over CSS selectors?
It targets elements the way users and assistive technologies see them, which is more stable when markup changes.
Q4What does baseURL do in the config?
It sets a default address so tests can call page.goto with relative paths.
Q5How do you debug a failing Playwright test as a beginner?
Run it with --debug to step through, or record a trace and open it in the trace viewer.
SECTION 07Test yourself — playwright for beginners quiz
Five questions. No sign-up.
0 / 5Pick an answer to see why it is right or wrong.
SECTION 08Frequently asked questions
Is Playwright good for beginners?
Yes. Its setup command, codegen, auto-waiting and clear errors make it one of the easier automation tools to start with.
Do I need to know JavaScript to learn Playwright?
Basic JavaScript or TypeScript helps; Playwright also supports Python, Java and .NET if you prefer those.
How long does it take to learn Playwright basics?
With daily practice, most beginners can write useful, stable tests within a few weeks.
Where can I practise Playwright for free?
Use official demo sites such as the TodoMVC demo and the Playwright documentation site, and public test-practice websites.
Should I learn Playwright or Selenium first?
Either works. Playwright is often quicker to start; Selenium is common in existing projects. Concepts transfer between them.
SECTION 09Related reads
Classroom & online · Noida
Start test automation with confidence
Our Automation Testing Training Course covers test design, automation frameworks, API testing and CI, giving you a strong base to learn tools like Playwright quickly.
Talk to a counsellor for current fees- Automation fundamentals
- Framework design
- API testing and CI
- Mock interviews