Playwright Tutorial with TypeScript: Free Course from Beginner to Advanced
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.
How This Playwright Course Works
Each topic is one short article that explains a single concept in plain language.
Copy and run TypeScript examples written for Playwright Test.
Solve the assignment at the end of each lesson and module.
Combine your skills in three real-world framework projects.
Your Learning Path
Playwright Tutorial Syllabus
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.
Module 2: JavaScript Essentials for Playwright
The JavaScript every Playwright tester needs: variables, control flow, functions, strings, arrays, objects, errors and async/await.
⚙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
.msiinstaller and leave “Add to PATH” ticked. - macOS: run the
.pkginstaller, 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
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
| Error | Fix |
|---|---|
'node' is not recognized | Restart 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 module | Add "type": "module" to package.json (step 5). |
- 08Variables
- 09Data Types
- 10Type Conversion
- 11Operators
- 12If Conditions
- 13Loops
- 14Functions
- 15Strings
- 16Array Methods
- 17Objects
- 18Exception Handling
- 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)
Module 3: TypeScript for Playwright
Add type safety: TypeScript basics through interfaces, classes and generics, each with Playwright examples.
⚙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
| Package | What it does |
|---|---|
typescript | Provides the tsc compiler, which checks types and converts .ts to .js. |
tsx | Runs a .ts file directly with no separate compile step. Handy for quick practice. |
@types/node | Type 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"]
}
| Option | Meaning |
|---|---|
target | The JavaScript version the compiler outputs. ES2022 supports modern syntax such as async/await. |
module / moduleResolution | How import/export work. NodeNext follows Node.js rules. |
rootDir / outDir | Your .ts files go in src/; compiled .js files go to dist/. |
strict | Turns on all strict type checks. Keep it on: it catches the most bugs. |
sourceMap | Lets 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
.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
| Error | Fix |
|---|---|
'tsc' is not recognized | TypeScript 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 file | Put your .ts files inside the src/ folder, as set in include. |
VS Code shows old errors after you change tsconfig.json | Press Ctrl+Shift+P and choose TypeScript: Restart TS Server. |
- 20TypeScript Variables
- 21TypeScript Data Types
- 22TypeScript Operators
- 23TypeScript Conditions
- 24TypeScript Loops
- 25TypeScript Functions
- 26TypeScript Arrays
- 27TypeScript Objects
- 28TypeScript Interfaces
- 29TypeScript Classes
- 30TypeScript Generics
- 31TypeScript OOP Practice Questions
- 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.
JavaScript practice programs
- ✎JavaScript Variables Programs
- ✎JavaScript Data Types Programs
- ✎JavaScript Type Conversion Programs
- ✎JavaScript Operators Programs
- ✎JavaScript If-Else Conditions Programs
- ✎JavaScript Loops Programs
- ✎JavaScript Functions Programs
- ✎JavaScript Strings Programs
- ✎JavaScript Arrays Programs
- ✎JavaScript Objects Programs
- ✎JavaScript Exception Handling Programs
- ✎JavaScript Promises and Async/Await Programs
TypeScript practice programs
- ✎TypeScript Variables and Types Programs
- ✎TypeScript Data Types Programs
- ✎TypeScript Operators Programs
- ✎TypeScript Conditions and Narrowing Programs
- ✎TypeScript Loops Programs
- ✎TypeScript Functions Programs
- ✎TypeScript Arrays and Tuples Programs
- ✎TypeScript Objects Programs
- ✎TypeScript Interfaces and Types Programs
- ✎TypeScript Classes Programs
- ✎TypeScript Generics Programs
- ✎TypeScript OOP Concepts Programs
Module 4: Locators and Interactions
Find any element reliably and interact with it: locators, selectors, actions, codegen, dialogs, frames, tabs, tables and files.
- 33Playwright Locators: Beginner to Advanced
- 34CSS and XPath Selectors in Playwright
- 35Actions: Click, Fill, Type, Check, Press and Hover
- 36Record Tests with Playwright Codegen
- 37Alerts, Popups, Dropdowns, iFrames and Tabs
- 38Reading Data from Web Tables
- 39File Downloads
📝 Test yourself: Module 4 mock test: locators and interactions (20 MCQs in 20 minutes)
Module 5: Assertions, Waits and Screenshots
Verify results with web-first assertions, wait the right way, and capture screenshots, videos and visual comparisons.
- 40Playwright Assertions: Complete Guide
- 41Playwright Waits Explained
- 42Screenshots and Video Recording
- 43Visual Regression Testing with toHaveScreenshot
📝 Test yourself: Module 5 mock test: assertions, waits and screenshots (20 MCQs in 20 minutes)
Module 6: Organizing Tests: Hooks, Fixtures and Annotations
Structure suites like a professional: hooks, describe blocks, tags, annotations, fixtures and retries for flaky tests.
- 44Hooks: beforeEach, afterEach, beforeAll, afterAll
- 45Group, Tag and Filter Tests (describe, tags, grep)
- 46Annotations: skip, only, fixme, slow
- 47Playwright Fixtures Step by Step
- 48Custom Fixtures with Examples
- 49Retries and Fixing Flaky Tests
📝 Test yourself: Module 6 mock test: hooks, fixtures and annotations (20 MCQs in 20 minutes)
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.
Module 8: Authentication and Network Control
Log in once and reuse sessions, test passkeys, and intercept or mock network requests.
- 57Save and Reuse Login Sessions (storageState)
- 58Network Interception and API Mocking
- 59Testing Passkey Login (WebAuthn)
📝 Test yourself: Module 8 mock test: authentication and network control (20 MCQs in 20 minutes)
Module 9: API Testing with Playwright
Automate REST APIs with the request fixture and combine API and UI steps in one framework.
📝 Test yourself: Module 9 mock test: API testing (20 MCQs in 20 minutes)
Module 10: Framework Design
Design a maintainable framework: Page Object Model, folder structure, design patterns, SOLID, BDD and an enterprise implementation.
- 62Page Object Model (POM) Step by Step
- 63Framework Folder Structure and Best Practices
- 64Design Patterns: Factory, Builder, Strategy
- 65SOLID Principles with Playwright
- 66BDD Integration
- 67Playwright BDD Framework Step by Step
- 68Real-World Enterprise Framework
📝 Test yourself: Module 10 mock test: framework design (20 MCQs in 20 minutes)
Module 11: Debugging and Reporting
Find failures fast with the Inspector, UI mode and Trace Viewer, and publish HTML and Allure reports.
- 69Debugging: Inspector, UI Mode and VS Code
- 70Trace Viewer Step by Step
- 71Reporters and the HTML Report
- 72Allure Report Integration
📝 Test yourself: Module 11 mock test: debugging and reporting (20 MCQs in 20 minutes)
Module 12: Parallel Execution and CI/CD
Scale your suite with workers and sharding, and run it automatically in GitHub Actions, Jenkins and Docker.
- 73Parallel Execution, Workers and Sharding
- 74Run Playwright Tests in GitHub Actions
- 75Run Playwright Tests in Jenkins
- 76Playwright with Docker and Kubernetes
📝 Test yourself: Module 12 mock test: parallel execution and CI/CD (20 MCQs in 20 minutes)
Module 13: AI-Powered Testing with Playwright
Use AI with Playwright: the Playwright MCP server, Playwright Test Agents and AI tools for QA engineers.
- 77Playwright MCP: Browser Automation with AI Agents
- 78Playwright Test Agents: Planner, Generator, Healer
- 79AI Tools for QA Engineers
📝 Test yourself: Module 13 mock test: AI-powered testing (20 MCQs in 20 minutes)
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.
Module 15: Interview Preparation
Prepare for Playwright interviews at every level, with a printable cheat sheet for quick revision.
- 85Playwright Interview Questions and Answers
- 86Locator Interview Questions
- 87Assertions Interview Questions
- 88200 Playwright + TypeScript Questions
- 89Interview Questions for Experienced (2, 3, 5+ Years)
- 90AI + QA Automation Interview Questions
- 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
- Git and GitHub Tutorial: version control, pull requests and GitHub Actions CI/CD for your test projects
- Playwright and QA Automation Training Notes: GitHub, GitHub Actions, AI and SQL notes
- SqaToolsByDY on YouTube: video walkthroughs of the lessons