Playwright Python and Pytest for Web Automation Testing: Master Modern Web Testing with Playwright and Pytest in Python
9h 34mIntermediate2026-02-27
Authors

Packt Publishing
Course details
Unlock the full potential of web automation testing using Playwright and Pytest in Python. This course takes you from installation and setup to advanced testing workflows, guiding you through browser automation, UI interaction, and reliable locator strategies. Learn how to simulate real-world user actions, manage asynchronous events, and validate application behavior through dynamic and robust tests. With extensive Pytest integration, you'll structure scalable test suites using fixtures, scopes, and reusable components. Explore file uploads, keyboard events, event listeners, and assertions with hands-on examples. Build advanced frameworks using the Page Object Model, handle authentication scenarios, and test network and API flows effectively. You’ll also optimize performance through parallel test execution, request interception, and JavaScript disabling. Implement CI/CD automation with GitHub Actions, apply data-driven techniques with pytest.mark.parametrize, and dive into BDD workflows using Behave. Designed for technical professionals, this course helps you conquer modern testing processes with practical, maintainable, and production-ready code.
Learning objectives
Install and configure Playwright for Python-based testing.
Identify and interact with web elements using diverse locator strategies.
Automate complex user actions and handle asynchronous events.
Build and maintain test frameworks using Pytest and fixtures.
Integrate Playwright tests with CI pipelines using GitHub Actions.
Validate UI and API behaviors with end-to-end automation.
Implement the Page Object Model and test dynamic applications effectively.
Learning objectives
Install and configure Playwright for Python-based testing.
Identify and interact with web elements using diverse locator strategies.
Automate complex user actions and handle asynchronous events.
Build and maintain test frameworks using Pytest and fixtures.
Integrate Playwright tests with CI pipelines using GitHub Actions.
Validate UI and API behaviors with end-to-end automation.
Implement the Page Object Model and test dynamic applications effectively.
Concepts
Getting Started
- Playwright installation
- Playwright docs
- Launching browser
- Clicking link element
- Script overview
Locators
- Playwright Python REPL
- Locator role
- Locators input field
- Locator text
- Locator alt text
- Locator title
- Locating with CSS selectors
- CSS selectors hierarchy
- CSS selectors pseudo classes
- Locators XPath
- XPath functions
- Other locators
Actions
- Mouse actions
- Actions text input
- Radios, checkboxes, and switches
- Select option
- Dropdown menu
- Upload files
- Keyboard shortcuts
Events
- Playwright auto-waiting
- Auto-waiting navigation
- Custom waiting
- Event listeners
- Handling dialogs
- Download files
- What is sync and async
- Asynchronous Playwright
Authentication
- Google sign in
- Save authentication state
- Reuse auth state
- Google login issue
Automated Mail Checker
- Automatic mail checker
- Project setup
- Locate new emails
- Locate email data
- Combine locators
- Check email from terminal
Pytest
- Testing Pytest
- Writing test
- Running test
- Type hinting
- Test state
- Pytest fixture
- Using fixture
- Fixture scope
pytest-playwright Plugin
- Install pytest-playwright plugin
- Playwright test
- Running test
- Pytest config
- Test hook
Playwright Tools
- Take screenshot
- Record video
- Trace generator and viewer
- Playwright codegen
Web-First Assertions
- Assertions page
- Assertions element state
- Assertions element text
- Assertions attribute
- Assertions input field
- Assertions checkbox
- Assertions option menu
UI Testing Playground
- UI testing dynamic ID
- UI testing class attribute
- UI testing hidden layer
- UI testing load delay
- UI testing AJAX request
- UI testing click action
- UI testing input field
- UI testing scrollbars
- UI testing dynamic table
- UI testing verify text
- UI testing progress bar
- UI testing visibility
- UI testing app login
- UI testing mouse hover
- UI testing nbsp character
- UI testing overlapped
Playwright Fixtures
- Function scope fixtures
- Session scope fixtures
- Browser selection
- Browser launch and context arguments
Page Object Model (POM)
- What is page object model
- Page object model implementation
- Page object model usage
- Playwright homepage POM
- POM usage
Network Events
- Network events
- Handle requests
- Modify response
API Testing
- Making an API call
- API request context
- API query string
- CRUD operations
- Mock API
Optimization
- Intercept requests
- Disabling JavaScript
- Run tests in parallel
Tips and Tricks
- Pytest CLI arguments
- Python debugger
- Device emulation
- Evaluate JavaScript
- Generate reports
GitHub API
- GitHub API introduction
- Project setup
- GitHub token
- Authorized API context
- Writing tests
- Running tests
Continuous Integration (CI)
- GitHub CI introduction
- Setup repository
- Writing tests
- GitHub action
- Running automated tests
Data-Driven Testing
- What is data-driven testing
- Pytest parametrize
- Running test
Behavior-Driven Development (BDD)
- Implement steps
- Running tests
- What is behavior-driven development
- Project setup
- Define feature