Playwright Tutorial with TypeScript: Free Course from Beginner to Advanced

Free Course · Updated October 2026

Learn Playwright with TypeScript, from Your First Test to a CI-Ready Framework

A complete, step-by-step Playwright tutorial for beginners and working testers. Every lesson is a separate, focused article with runnable TypeScript code, and the course builds up to real projects, practice assignments and interview preparation.

15Modules
91Lessons
3Real projects
100%Free

How This Playwright Course Works

1. Learn

Each topic is one short article that explains a single concept in plain language.

2. Code

Copy and run TypeScript examples written for Playwright Test.

3. Practise

Solve the assignment at the end of each lesson and module.

4. Build

Combine your skills in three real-world framework projects.

Your Learning Path

Playwright Tutorial Syllabus

1

Module 1: Getting Started with Playwright

Understand what Playwright is, install it, write your first test and learn the project structure, config file and CLI.

Beginner7 lessons
  1. 01What Is Playwright? Features and Architecture
  2. 02Automation Testing Fundamentals
  3. 03Playwright vs Selenium vs Cypress
  4. 04Install Playwright and Set Up VS Code
  5. 05Write and Run Your First Playwright Test
  6. 06playwright.config.ts Explained
  7. 07Playwright CLI: Run, Filter and Debug Tests

📝 Test yourself: Module 1 mock test (20 MCQs in 20 minutes)

2

Module 2: JavaScript Essentials for Playwright

The JavaScript every Playwright tester needs: variables, control flow, functions, strings, arrays, objects, errors and async/await.

Beginner12 lessons
⚙Before you start: Install and configure JavaScript (Node.js)6 setup steps to run every example in lessons 08 to 19

1Install Node.js (LTS)

Download the LTS version from nodejs.org and run the installer with the default options. npm (the Node package manager) is installed with it.

  • Windows: run the .msi installer and leave “Add to PATH” ticked.
  • macOS: run the .pkg installer, or use Homebrew: brew install node.
  • Linux: use your package manager or nvm: nvm install --lts.

2Verify the installation

Open a new terminal (Command Prompt, PowerShell or Terminal) and run:

node -v
npm -v

You should see version numbers such as v24.x.x and 11.x.x. If you see “command not found”, close the terminal, open a new one and try again.

3Install Visual Studio Code

Download VS Code from code.visualstudio.com, then add these extensions from the Extensions panel (Ctrl+Shift+X):

  • ESLint: highlights common JavaScript mistakes.
  • Prettier – Code formatter: formats your code on save.
  • Playwright Test for VS Code: you will need it from Module 4 onwards.

4Create a practice project

mkdir js-for-playwright
cd js-for-playwright
npm init -y
code .

npm init -y creates a package.json file, which stores your project settings and scripts.

5Configure package.json

Add "type": "module" so you can use modern import/export syntax, and add a start script:

{
  "name": "js-for-playwright",
  "version": "1.0.0",
  "type": "module",
  "scripts": {
    "start": "node index.js"
  }
}

6Write and run your first JavaScript file

Create index.js in the project folder:

const tool = "Playwright";
const version = process.version;

console.log(`Hello ${tool}! Running on Node ${version}`);

Run it from the VS Code terminal (Ctrl+`):

node index.js
# or
npm start

Expected output: Hello Playwright! Running on Node v24.x.x

Tip: type node on its own to open the Node REPL and try one line at a time (press Ctrl+C twice to exit). For each lesson, create a new file such as 08-variables.js and run it with node 08-variables.js.

Common problems

ErrorFix
'node' is not recognizedRestart the terminal or VS Code. If it still fails, reinstall Node.js with “Add to PATH” ticked.
npm.ps1 cannot be loaded because running scripts is disabled (Windows PowerShell)Run Set-ExecutionPolicy -Scope CurrentUser RemoteSigned once, or use Command Prompt instead.
Cannot use import statement outside a moduleAdd "type": "module" to package.json (step 5).
  1. 08Variables
  2. 09Data Types
  3. 10Type Conversion
  4. 11Operators
  5. 12If Conditions
  6. 13Loops
  7. 14Functions
  8. 15Strings
  9. 16Array Methods
  10. 17Objects
  11. 18Exception Handling
  12. 19Promises and Async/Await for Playwright

📝 Test yourself: Module 2 mock test: JavaScript MCQs (20 questions in 20 minutes)

✎ Practise this module: JavaScript programs with solutions (30+ per topic)

3

Module 3: TypeScript for Playwright

Add type safety: TypeScript basics through interfaces, classes and generics, each with Playwright examples.

Beginner13 lessons
⚙Before you start: Install and configure TypeScript6 setup steps to compile and run every example in lessons 20 to 32

TypeScript is JavaScript with types. Node.js runs JavaScript, so TypeScript is either compiled to JavaScript first or run with a tool that handles it for you. These steps set up both ways.

Prerequisite: Node.js and VS Code installed (see the JavaScript setup in Module 2).

1Create a TypeScript project

mkdir ts-for-playwright
cd ts-for-playwright
npm init -y
code .

2Install TypeScript and helpers

Install them as development dependencies inside the project, so every project keeps its own version:

npm install --save-dev typescript tsx @types/node
PackageWhat it does
typescriptProvides the tsc compiler, which checks types and converts .ts to .js.
tsxRuns a .ts file directly with no separate compile step. Handy for quick practice.
@types/nodeType definitions for Node.js, so console, process and similar names are recognized.

Check the version with npx tsc -v.

3Create tsconfig.json

Generate the config file with npx tsc --init, then replace its contents with this beginner-friendly config:

{
  "compilerOptions": {
    "target": "ES2022",
    "module": "NodeNext",
    "moduleResolution": "NodeNext",
    "rootDir": "src",
    "outDir": "dist",
    "strict": true,
    "esModuleInterop": true,
    "skipLibCheck": true,
    "sourceMap": true
  },
  "include": ["src"]
}
OptionMeaning
targetThe JavaScript version the compiler outputs. ES2022 supports modern syntax such as async/await.
module / moduleResolutionHow import/export work. NodeNext follows Node.js rules.
rootDir / outDirYour .ts files go in src/; compiled .js files go to dist/.
strictTurns on all strict type checks. Keep it on: it catches the most bugs.
sourceMapLets the debugger map errors back to your .ts lines.

4Add npm scripts

Add these scripts to package.json:

"scripts": {
  "build": "tsc",
  "start": "node dist/index.js",
  "dev": "tsx watch src/index.ts",
  "typecheck": "tsc --noEmit"
}

5Write and run your first TypeScript file

Create src/index.ts:

type Browser = "chromium" | "firefox" | "webkit";

function launchMessage(browser: Browser, headless: boolean = true): string {
  return `Launching ${browser} (headless: ${headless})`;
}

console.log(launchMessage("chromium"));
// console.log(launchMessage("safari")); // Error: "safari" is not a valid Browser

Option A: compile, then run

npm run build      # creates dist/index.js
npm start          # runs the compiled JavaScript

Option B: run directly (fastest for practice)

npx tsx src/index.ts
# or re-run automatically on every save:
npm run dev

Expected output: Launching chromium (headless: true)

Now remove the // from the last line and run npm run typecheck. TypeScript reports the error before the code runs, which is the main reason Playwright projects use TypeScript.

6Recommended folder structure

ts-for-playwright/
├── src/
│   ├── index.ts
│   ├── 20-ts-variables.ts
│   └── 21-ts-datatypes.ts
├── dist/            (generated by tsc, do not edit)
├── package.json
└── tsconfig.json
How this connects to Playwright: Playwright Test runs .ts test files directly, so you do not need tsc before npx playwright test. Playwright does not check types, though, so run npx tsc --noEmit before you push code or in CI. Lesson 04 creates a full Playwright TypeScript project with npm init playwright@latest.

Common problems

ErrorFix
'tsc' is not recognizedTypeScript is installed locally, so use npx tsc or the npm scripts instead of calling tsc directly.
Cannot find name 'console' or 'process'Install the Node types: npm install --save-dev @types/node.
No inputs were found in config filePut your .ts files inside the src/ folder, as set in include.
VS Code shows old errors after you change tsconfig.jsonPress Ctrl+Shift+P and choose TypeScript: Restart TS Server.
  1. 20TypeScript Variables
  2. 21TypeScript Data Types
  3. 22TypeScript Operators
  4. 23TypeScript Conditions
  5. 24TypeScript Loops
  6. 25TypeScript Functions
  7. 26TypeScript Arrays
  8. 27TypeScript Objects
  9. 28TypeScript Interfaces
  10. 29TypeScript Classes
  11. 30TypeScript Generics
  12. 31TypeScript OOP Practice Questions
  13. 32TypeScript for Playwright: Complete Guide

📝 Test yourself: Module 3 mock test: TypeScript MCQs (20 questions in 20 minutes)

✎ Practise this module: TypeScript programs with solutions (30+ per topic)

✎

JavaScript & TypeScript Program Practice

Hands-on coding practice for Modules 2 and 3: 30+ programs per topic with solutions, outputs and explanations, from beginner exercises to real-world test automation scenarios.

Practice24 topics30+ programs eachWith solutions

JavaScript practice programs

  1. ✎JavaScript Variables Programs
  2. ✎JavaScript Data Types Programs
  3. ✎JavaScript Type Conversion Programs
  4. ✎JavaScript Operators Programs
  5. ✎JavaScript If-Else Conditions Programs
  6. ✎JavaScript Loops Programs
  7. ✎JavaScript Functions Programs
  8. ✎JavaScript Strings Programs
  9. ✎JavaScript Arrays Programs
  10. ✎JavaScript Objects Programs
  11. ✎JavaScript Exception Handling Programs
  12. ✎JavaScript Promises and Async/Await Programs

TypeScript practice programs

  1. ✎TypeScript Variables and Types Programs
  2. ✎TypeScript Data Types Programs
  3. ✎TypeScript Operators Programs
  4. ✎TypeScript Conditions and Narrowing Programs
  5. ✎TypeScript Loops Programs
  6. ✎TypeScript Functions Programs
  7. ✎TypeScript Arrays and Tuples Programs
  8. ✎TypeScript Objects Programs
  9. ✎TypeScript Interfaces and Types Programs
  10. ✎TypeScript Classes Programs
  11. ✎TypeScript Generics Programs
  12. ✎TypeScript OOP Concepts Programs
4

Module 4: Locators and Interactions

Find any element reliably and interact with it: locators, selectors, actions, codegen, dialogs, frames, tabs, tables and files.

Beginner7 lessons
  1. 33Playwright Locators: Beginner to Advanced
  2. 34CSS and XPath Selectors in Playwright
  3. 35Actions: Click, Fill, Type, Check, Press and Hover
  4. 36Record Tests with Playwright Codegen
  5. 37Alerts, Popups, Dropdowns, iFrames and Tabs
  6. 38Reading Data from Web Tables
  7. 39File Downloads

📝 Test yourself: Module 4 mock test: locators and interactions (20 MCQs in 20 minutes)

5

Module 5: Assertions, Waits and Screenshots

Verify results with web-first assertions, wait the right way, and capture screenshots, videos and visual comparisons.

Beginner4 lessons
  1. 40Playwright Assertions: Complete Guide
  2. 41Playwright Waits Explained
  3. 42Screenshots and Video Recording
  4. 43Visual Regression Testing with toHaveScreenshot

📝 Test yourself: Module 5 mock test: assertions, waits and screenshots (20 MCQs in 20 minutes)

6

Module 6: Organizing Tests: Hooks, Fixtures and Annotations

Structure suites like a professional: hooks, describe blocks, tags, annotations, fixtures and retries for flaky tests.

Intermediate6 lessons
  1. 44Hooks: beforeEach, afterEach, beforeAll, afterAll
  2. 45Group, Tag and Filter Tests (describe, tags, grep)
  3. 46Annotations: skip, only, fixme, slow
  4. 47Playwright Fixtures Step by Step
  5. 48Custom Fixtures with Examples
  6. 49Retries and Fixing Flaky Tests

📝 Test yourself: Module 6 mock test: hooks, fixtures and annotations (20 MCQs in 20 minutes)

7

Module 7: Test Data, Configuration and Cross-Browser

Drive tests from data files and environment variables, manage configs, and run across browsers and mobile devices.

Intermediate7 lessons
  1. 50Data-Driven (Parameterized) Tests
  2. 51Read Test Data from JSON
  3. 52Read Test Data from CSV
  4. 53Environment Variables with .env
  5. 54Multiple Config Files for API and UI
  6. 55Cross-Browser Testing with Projects
  7. 56Mobile Device Emulation

📝 Test yourself: Module 7 mock test: test data, configuration and cross-browser (20 MCQs in 20 minutes)

8

Module 8: Authentication and Network Control

Log in once and reuse sessions, test passkeys, and intercept or mock network requests.

Intermediate3 lessons
  1. 57Save and Reuse Login Sessions (storageState)
  2. 58Network Interception and API Mocking
  3. 59Testing Passkey Login (WebAuthn)

📝 Test yourself: Module 8 mock test: authentication and network control (20 MCQs in 20 minutes)

9

Module 9: API Testing with Playwright

Automate REST APIs with the request fixture and combine API and UI steps in one framework.

Intermediate2 lessons
  1. 60API Testing: GET, POST, PUT, DELETE
  2. 61API Automation with Page Object Model

📝 Test yourself: Module 9 mock test: API testing (20 MCQs in 20 minutes)

10

Module 10: Framework Design

Design a maintainable framework: Page Object Model, folder structure, design patterns, SOLID, BDD and an enterprise implementation.

Advanced7 lessons
  1. 62Page Object Model (POM) Step by Step
  2. 63Framework Folder Structure and Best Practices
  3. 64Design Patterns: Factory, Builder, Strategy
  4. 65SOLID Principles with Playwright
  5. 66BDD Integration
  6. 67Playwright BDD Framework Step by Step
  7. 68Real-World Enterprise Framework

📝 Test yourself: Module 10 mock test: framework design (20 MCQs in 20 minutes)

11

Module 11: Debugging and Reporting

Find failures fast with the Inspector, UI mode and Trace Viewer, and publish HTML and Allure reports.

Advanced4 lessons
  1. 69Debugging: Inspector, UI Mode and VS Code
  2. 70Trace Viewer Step by Step
  3. 71Reporters and the HTML Report
  4. 72Allure Report Integration

📝 Test yourself: Module 11 mock test: debugging and reporting (20 MCQs in 20 minutes)

12

Module 12: Parallel Execution and CI/CD

Scale your suite with workers and sharding, and run it automatically in GitHub Actions, Jenkins and Docker.

Advanced4 lessons
  1. 73Parallel Execution, Workers and Sharding
  2. 74Run Playwright Tests in GitHub Actions
  3. 75Run Playwright Tests in Jenkins
  4. 76Playwright with Docker and Kubernetes

📝 Test yourself: Module 12 mock test: parallel execution and CI/CD (20 MCQs in 20 minutes)

13

Module 13: AI-Powered Testing with Playwright

Use AI with Playwright: the Playwright MCP server, Playwright Test Agents and AI tools for QA engineers.

Advanced3 lessons
  1. 77Playwright MCP: Browser Automation with AI Agents
  2. 78Playwright Test Agents: Planner, Generator, Healer
  3. 79AI Tools for QA Engineers

📝 Test yourself: Module 13 mock test: AI-powered testing (20 MCQs in 20 minutes)

14

Module 14: Real-World Projects and Assignments

Apply everything in hands-on projects and module-wise assignments, from a first project to a CI-ready hybrid framework.

Project5 lessons
  1. 80Project 1: Beginner Automation Project
  2. 81Project 2: E-commerce E2E Framework
  3. 82Project 3: API + UI Hybrid Framework with CI
  4. 83Module-wise Practice Assignments
  5. 84Playwright Testing Practice Exercises
15

Module 15: Interview Preparation

Prepare for Playwright interviews at every level, with a printable cheat sheet for quick revision.

Career7 lessons
  1. 85Playwright Interview Questions and Answers
  2. 86Locator Interview Questions
  3. 87Assertions Interview Questions
  4. 88200 Playwright + TypeScript Questions
  5. 89Interview Questions for Experienced (2, 3, 5+ Years)
  6. 90AI + QA Automation Interview Questions
  7. 91Playwright Cheat Sheet

📝 Playwright mock interview: timed MCQ tests and your interview readiness score

Who This Course Is For

  • Manual testers moving into automation: no coding background needed, Modules 2 and 3 teach the language.
  • Selenium or Cypress engineers switching to Playwright: start with Playwright vs Selenium vs Cypress, then jump to Module 4.
  • SDETs and automation leads designing frameworks: focus on Modules 9 to 13 and the projects.
  • Job seekers preparing for Playwright interviews: Module 15.

What You Need

  • A computer with Windows, macOS or Linux and the latest LTS version of Node.js.
  • Visual Studio Code with the Playwright Test extension (installation is covered in Lesson 4).
  • Practice sites: SQA Tools automation practice pages and other free demo apps used in the lessons.

Playwright Course FAQs

Is this Playwright tutorial free?

Yes. Every lesson, code example, project and assignment in this Playwright with TypeScript course is free to read on SQA Tools.

Do I need programming experience to start?

No. Modules 2 and 3 teach the JavaScript and TypeScript you need from scratch, so complete beginners and manual testers can follow the course in order.

How long does it take to complete the course?

Studying 1 to 2 hours a day, most learners finish the beginner modules in 3 to 4 weeks and the full course, including projects, in about 2 to 3 months.

Why learn Playwright with TypeScript instead of JavaScript?

TypeScript gives autocomplete and catches mistakes before tests run, and Playwright runs TypeScript with zero setup. It is the most common combination in Playwright job descriptions.

Will I build a real framework?

Yes. The course ends with three projects: a beginner project, an e-commerce end-to-end framework, and an API + UI hybrid framework running in CI with GitHub Actions.

Is Playwright good for getting a QA automation job?

Playwright is the fastest-growing web automation tool and is widely requested in QA automation and SDET roles. Module 15 prepares you for interviews from fresher to experienced level.

More Free Resources