This repository contains a test automation framework built with Playwright and Pytest in Python. It serves as a practical application of the concepts and techniques learned from the "Playwright PYTHON Automation Testing - From Zero to Expert" course on Udemy.
This project is based on the teachings from the following Udemy course:
This project demonstrates experience and understanding in the following areas:
- Python Fundamentals: Core concepts of the Python programming language.
- Playwright for Browser Automation:
- Interacting with web pages, using selectors, and navigating between pages.
- Handling network interception and mocking for API and hybrid testing.
- Performing API testing directly with Playwright's request context.
- Visual testing, including taking screenshots and performing comparisons.
- Emulating mobile devices and testing responsive designs.
- Playwright Tools:
- Inspector: For debugging and inspecting page elements.
- Trace Viewer: To get a detailed trace of test execution.
- CodeGen: For recording user interactions and generating test scripts.
- Pytest for Test Management:
- Writing and organizing tests.
- Using fixtures for setup and teardown.
- Parameterizing tests to run with different data sets.
- Test Automation Framework Design:
- Structuring the framework with a modular approach using Page Object Model (POM).
- Creating reusable utilities and configuration modules.
- Behavior-Driven Development (BDD):
- Incorporating BDD principles with Gherkin (
.featurefiles) andpytest-bdd.
- Incorporating BDD principles with Gherkin (
- CI/CD and Reporting:
- Running tests in a containerized environment using Docker.
- Generating comprehensive test reports.
- Capturing screenshots, videos, and traces on test failure.
- Best Practices:
- Writing maintainable, readable, and scalable test code.
- Applying the principle of separation of concerns in the framework design.
- Python 3.10+
- pip
- Virtualenv (recommended)
-
Clone the repository:
git clone <repository-url> cd playwright_pytest_course
-
Create and activate a virtual environment:
python -m venv venv source venv/bin/activate # On Windows, use `venv\Scripts\activate`
-
Install the dependencies:
pip install -r requirements.txt
-
Create a
.envfile in the root of the project and add the necessary credentials:EMAIL=<your_email> PASSWORD=<your_password> PST_EMAIL=<your_pst_email> PST_PASSWORD=<your_pst_password>
To run the tests, use the following command:
pytestYou can also specify a browser to run the tests against:
pytest --browser_name <browser>Supported browsers are chrome, firefox, and edge.