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.
How This Playwright Python Course Works
Each topic is one article that explains a single concept in plain language.
Copy and run pytest examples, every one tested before publishing.
Take the timed 20-question mock interview for each module.
Combine your skills in three real-world framework projects.
Your Learning Path
Playwright Python Tutorial Syllabus
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.
- 01What Is Playwright for Python? Sync API, Async API and pytest
- 02Install Python, Playwright and pytest (venv and VS Code)
- 03Your First Playwright Script with sync_playwright
- 04Write and Run Your First pytest Playwright Test
- 05Run Tests: pytest and pytest-playwright CLI Options
- 06Configure Tests: pytest.ini, pyproject.toml and conftest.py
- 07Record Tests with Playwright Codegen for Python
📝 Test yourself: Module 1 mock interview (20 MCQs in 20 minutes)
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.
- 08Python Variables
- 09Python Data Types
- 10Python If Else
- 11Python Loops
- 12Python Strings
- 13Python Lists
- 14Python Dictionaries
- 15Python Functions
- 16Python Exception Handling
- 17Python OOP
- 18Python Decorators
- 19Python Modules, Packages and Imports for Test Projects
- 20Python Virtual Environments and pip
- 21Python Type Hints for Playwright Tests
- 22Python Context Managers and the with Statement
- 23Python async/await and asyncio for Playwright
📝 Test yourself: Module 2 mock interview (20 MCQs in 20 minutes)
Module 3: pytest Fundamentals
Master the test runner: discovery, assert, fixtures and scopes, conftest.py, parametrize, markers, configuration, plugins and hooks.
- 24pytest Basics: Test Discovery, assert and Running Tests
- 25pytest Fixtures: Setup, Teardown, Scope and yield
- 26Sharing Fixtures with conftest.py
- 27Parametrize Tests with @pytest.mark.parametrize
- 28pytest Markers: skip, skipif, xfail and Custom Markers
- 29pytest Configuration: pytest.ini, pyproject.toml and addopts
- 30pytest Plugins and Hooks: pytest_addoption and More
📝 Test yourself: Module 3 mock interview (20 MCQs in 20 minutes)
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.
- 31Playwright Python Locators: get_by_role and Friends
- 32CSS and XPath Selectors in Playwright Python
- 33Actions: click, fill, press, check, select_option and hover
- 34Dialogs, iFrames, Popups and New Tabs
- 35Read Data from Web Tables
- 36File Upload and File Download
📝 Test yourself: Module 4 mock interview (20 MCQs in 20 minutes)
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.
- 37Playwright Python Assertions with expect
- 38Auto-Waiting and Explicit Waits in Python
- 39Screenshots, Videos and Traces on Failure
- 40Visual Regression Testing in Python
📝 Test yourself: Module 5 mock interview (20 MCQs in 20 minutes)
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.
- 41pytest-playwright Built-in Fixtures Explained
- 42Custom Fixtures for Playwright Tests
- 43Browser Markers: skip_browser, only_browser and browser_context_args
- 44Retries and Flaky Tests with pytest-rerunfailures
📝 Test yourself: Module 6 mock interview (20 MCQs in 20 minutes)
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.
- 45Data-Driven Tests with parametrize Coming soon
- 46Read Test Data from JSON, CSV and Excel Coming soon
- 47Environment Variables and .env Files Coming soon
- 48Run Against Multiple Environments (–base-url and Custom Options) Coming soon
- 49Cross-Browser Testing in Python Coming soon
- 50Mobile Device Emulation Coming soon
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.
- 51Save and Reuse Login State (storage_state) Coming soon
- 52Network Interception and API Mocking with route Coming soon
- 53Record and Replay Network Traffic with HAR Coming soon
Module 9: API Testing with Playwright Python
Automate REST APIs with APIRequestContext and combine API and UI steps in the same pytest suite.
- 54API Testing: GET, POST, PUT, DELETE with APIRequestContext Coming soon
- 55Combine API and UI Tests Coming soon
Module 10: Framework Design
Design a maintainable Python framework: Page Object Model, folder structure, design patterns, pytest-bdd and an enterprise implementation.
- 56Page Object Model in Python Step by Step Coming soon
- 57Framework Folder Structure and Best Practices Coming soon
- 58Design Patterns for Playwright Python Frameworks Coming soon
- 59BDD with pytest-bdd and Playwright Coming soon
- 60Real-World Enterprise Framework in Python Coming soon
Module 11: Debugging and Reporting
Find failures fast with the Inspector, PWDEBUG and the Trace Viewer, and publish pytest-html and Allure reports.
- 61Debugging: Inspector, PWDEBUG, page.pause and breakpoint Coming soon
- 62Trace Viewer for Python Tests Coming soon
- 63HTML Reports with pytest-html Coming soon
- 64Allure Reports with allure-pytest Coming soon
Module 12: Parallel Execution and CI/CD
Scale your suite with pytest-xdist and run it automatically in GitHub Actions, Jenkins and Docker.
- 65Parallel Execution with pytest-xdist Coming soon
- 66Run Playwright Python Tests in GitHub Actions Coming soon
- 67Run Playwright Python Tests in Jenkins Coming soon
- 68Playwright Python in Docker Coming soon
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.
- 69The Async API: async_playwright and pytest-playwright-asyncio Coming soon
- 70Playwright MCP and playwright-cli for Python Testers Coming soon
- 71AI Tools for Python Test Automation (and What Is JS-Only) Coming soon
Module 14: Real-World Projects
Apply everything in three hands-on projects, from a first project to a CI-ready API + UI framework.
- 72Project 1: Beginner Automation Project Coming soon
- 73Project 2: E-commerce End-to-End Framework Coming soon
- 74Project 3: API + UI Hybrid Framework with CI Coming soon
Module 15: Interview Preparation
Prepare for Playwright Python and pytest interviews, with a cheat sheet for quick revision.
- 75Playwright Python Interview Questions and Answers Coming soon
- 76pytest Interview Questions and Answers Coming soon
- 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
- Playwright with TypeScript Tutorial: the same course for TypeScript and Playwright Test
- Python Tutorials and Python Practice Exercises
- Git and GitHub Tutorial: version control and GitHub Actions for your test projects
- SqaToolsByDY on YouTube: video walkthroughs