Playwright with Python & Pytest Tutorial: Free Course from Beginner to Advanced

Free Course · Updated November 2026

Learn Playwright with Python & pytest, from Your First Test to a CI-Ready Framework

A complete, step-by-step Playwright for Python tutorial for beginners and working testers. Every lesson is a focused article with pytest code that is run and verified before publishing, plus a timed mock interview for each module.

15Modules
77Lessons
13Mock interviews
100%Free

How This Playwright Python Course Works

1. Learn

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

2. Code

Copy and run pytest examples, every one tested before publishing.

3. Test yourself

Take the timed 20-question mock interview for each module.

4. Build

Combine your skills in three real-world framework projects.

Your Learning Path

Playwright Python Tutorial Syllabus

1

Module 1: Getting Started with Playwright for Python

Understand Playwright for Python, set up Python, pytest and the browsers, write your first script and tests, and learn the CLI, configuration and Codegen.

Beginner7 lessons
  1. 01What Is Playwright for Python? Sync API, Async API and pytest
  2. 02Install Python, Playwright and pytest (venv and VS Code)
  3. 03Your First Playwright Script with sync_playwright
  4. 04Write and Run Your First pytest Playwright Test
  5. 05Run Tests: pytest and pytest-playwright CLI Options
  6. 06Configure Tests: pytest.ini, pyproject.toml and conftest.py
  7. 07Record Tests with Playwright Codegen for Python

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

2

Module 2: Python Essentials for Playwright

The Python every Playwright tester needs, from variables to OOP, plus modules, virtual environments, type hints, context managers and async/await.

Beginner16 lessons
  1. 08Python Variables
  2. 09Python Data Types
  3. 10Python If Else
  4. 11Python Loops
  5. 12Python Strings
  6. 13Python Lists
  7. 14Python Dictionaries
  8. 15Python Functions
  9. 16Python Exception Handling
  10. 17Python OOP
  11. 18Python Decorators
  12. 19Python Modules, Packages and Imports for Test Projects
  13. 20Python Virtual Environments and pip
  14. 21Python Type Hints for Playwright Tests
  15. 22Python Context Managers and the with Statement
  16. 23Python async/await and asyncio for Playwright

📝 Test yourself: Module 2 mock interview (20 MCQs in 20 minutes)

3

Module 3: pytest Fundamentals

Master the test runner: discovery, assert, fixtures and scopes, conftest.py, parametrize, markers, configuration, plugins and hooks.

Beginner7 lessons
  1. 24pytest Basics: Test Discovery, assert and Running Tests
  2. 25pytest Fixtures: Setup, Teardown, Scope and yield
  3. 26Sharing Fixtures with conftest.py
  4. 27Parametrize Tests with @pytest.mark.parametrize
  5. 28pytest Markers: skip, skipif, xfail and Custom Markers
  6. 29pytest Configuration: pytest.ini, pyproject.toml and addopts
  7. 30pytest Plugins and Hooks: pytest_addoption and More

📝 Test yourself: Module 3 mock interview (20 MCQs in 20 minutes)

4

Module 4: Locators and Interactions

Find any element reliably and interact with it: role-based locators, CSS and XPath, actions, dialogs, frames, tabs, tables and files.

Beginner6 lessons
  1. 31Playwright Python Locators: get_by_role and Friends
  2. 32CSS and XPath Selectors in Playwright Python
  3. 33Actions: click, fill, press, check, select_option and hover
  4. 34Dialogs, iFrames, Popups and New Tabs
  5. 35Read Data from Web Tables
  6. 36File Upload and File Download

📝 Test yourself: Module 4 mock interview (20 MCQs in 20 minutes)

5

Module 5: Assertions, Waits and Screenshots

Verify results with expect, understand auto-waiting, and capture screenshots, videos and traces, including visual regression options in Python.

Beginner4 lessons
  1. 37Playwright Python Assertions with expect
  2. 38Auto-Waiting and Explicit Waits in Python
  3. 39Screenshots, Videos and Traces on Failure
  4. 40Visual Regression Testing in Python

📝 Test yourself: Module 5 mock interview (20 MCQs in 20 minutes)

6

Module 6: pytest-playwright Fixtures and Test Organisation

Use pytest-playwright fixtures like a professional, write custom fixtures, control browsers with markers and handle flaky tests.

Intermediate4 lessons
  1. 41pytest-playwright Built-in Fixtures Explained Coming soon
  2. 42Custom Fixtures for Playwright Tests Coming soon
  3. 43Browser Markers: skip_browser, only_browser and browser_context_args Coming soon
  4. 44Retries and Flaky Tests with pytest-rerunfailures Coming soon
7

Module 7: Test Data, Configuration and Cross-Browser

Drive tests from data files and environment variables, target several environments, and run across browsers and mobile devices.

Intermediate6 lessons
  1. 45Data-Driven Tests with parametrize Coming soon
  2. 46Read Test Data from JSON, CSV and Excel Coming soon
  3. 47Environment Variables and .env Files Coming soon
  4. 48Run Against Multiple Environments (–base-url and Custom Options) Coming soon
  5. 49Cross-Browser Testing in Python Coming soon
  6. 50Mobile Device Emulation Coming soon
8

Module 8: Authentication and Network Control

Log in once and reuse the session, intercept and mock network requests, and record and replay traffic with HAR files.

Intermediate3 lessons
  1. 51Save and Reuse Login State (storage_state) Coming soon
  2. 52Network Interception and API Mocking with route Coming soon
  3. 53Record and Replay Network Traffic with HAR Coming soon
9

Module 9: API Testing with Playwright Python

Automate REST APIs with APIRequestContext and combine API and UI steps in the same pytest suite.

Intermediate2 lessons
  1. 54API Testing: GET, POST, PUT, DELETE with APIRequestContext Coming soon
  2. 55Combine API and UI Tests Coming soon
10

Module 10: Framework Design

Design a maintainable Python framework: Page Object Model, folder structure, design patterns, pytest-bdd and an enterprise implementation.

Advanced5 lessons
  1. 56Page Object Model in Python Step by Step Coming soon
  2. 57Framework Folder Structure and Best Practices Coming soon
  3. 58Design Patterns for Playwright Python Frameworks Coming soon
  4. 59BDD with pytest-bdd and Playwright Coming soon
  5. 60Real-World Enterprise Framework in Python Coming soon
11

Module 11: Debugging and Reporting

Find failures fast with the Inspector, PWDEBUG and the Trace Viewer, and publish pytest-html and Allure reports.

Advanced4 lessons
  1. 61Debugging: Inspector, PWDEBUG, page.pause and breakpoint Coming soon
  2. 62Trace Viewer for Python Tests Coming soon
  3. 63HTML Reports with pytest-html Coming soon
  4. 64Allure Reports with allure-pytest Coming soon
12

Module 12: Parallel Execution and CI/CD

Scale your suite with pytest-xdist and run it automatically in GitHub Actions, Jenkins and Docker.

Advanced4 lessons
  1. 65Parallel Execution with pytest-xdist Coming soon
  2. 66Run Playwright Python Tests in GitHub Actions Coming soon
  3. 67Run Playwright Python Tests in Jenkins Coming soon
  4. 68Playwright Python in Docker Coming soon
13

Module 13: Async Playwright and AI-Powered Testing

Use the async API and pytest-playwright-asyncio, and apply AI tools such as Playwright MCP to Python test automation.

Advanced3 lessons
  1. 69The Async API: async_playwright and pytest-playwright-asyncio Coming soon
  2. 70Playwright MCP and playwright-cli for Python Testers Coming soon
  3. 71AI Tools for Python Test Automation (and What Is JS-Only) Coming soon
14

Module 14: Real-World Projects

Apply everything in three hands-on projects, from a first project to a CI-ready API + UI framework.

Projects & Career3 lessons
  1. 72Project 1: Beginner Automation Project Coming soon
  2. 73Project 2: E-commerce End-to-End Framework Coming soon
  3. 74Project 3: API + UI Hybrid Framework with CI Coming soon
15

Module 15: Interview Preparation

Prepare for Playwright Python and pytest interviews, with a cheat sheet for quick revision.

Projects & Career3 lessons
  1. 75Playwright Python Interview Questions and Answers Coming soon
  2. 76pytest Interview Questions and Answers Coming soon
  3. 77Playwright Python Cheat Sheet Coming soon

Who This Course Is For

  • Manual testers moving into automation: Module 2 covers the Python you need.
  • Selenium with Python engineers switching to Playwright: start with Module 1, then jump to Module 4.
  • Python developers and SDETs building frameworks: focus on Modules 3, 6 and 10 to 13.
  • Job seekers preparing for interviews: the module mock interviews plus Module 15.

What You Need

  • A computer with Windows, macOS or Linux and Python 3.10 or newer.
  • Visual Studio Code with the Python extension (set up in Lesson 2).
  • Practice sites: the SQA Tools Automation Practice Page and other free demo apps used in the lessons.

Playwright Python Course FAQs

Is this Playwright Python tutorial free?

Yes. Every lesson, code example, mock interview and project in this Playwright with Python and pytest course is free on SQA Tools.

Do I need programming experience to start?

No. Module 2 covers the Python you need, linking to the SQA Tools Python tutorial for the basics, so manual testers can follow the course in order.

Is the code in the lessons tested?

Yes. Every code example is run with pytest against real practice sites before it is published, and outputs shown in the lessons are copied from those runs.

Which versions does the course use?

Playwright for Python 1.64, pytest-playwright 0.10 and pytest 9, on Python 3.10 or newer.

Should I learn Playwright with Python or TypeScript?

Both use the same browser engine and concepts. Choose Python if your team already uses Python or pytest; choose TypeScript if you want the built-in Playwright Test runner and its AI test agents.

Is there a mock interview for each module?

Yes. Each module from 1 to 13 has a timed 20-question mock test drawn from a 200-question bank, and the hub tracks your overall interview readiness.

More Free Resources