config/
: Contains configuration files.conftest.py
: Pytest configuration and fixtures.pages/
: Contains page object models for web pages.components/
: Contains reusable UI components.tests/
: Contains test cases.README.md
: Project documentation..gitignore
: Git ignore file.requirements.txt
: List of dependencies.
- Python 3.7+
- pip (Python package installer)
-
Clone the repository:
git clone <repository-url> cd automation_project
-
Create a virtual environment:
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install required packages:
pip install -r requirements.txt playwright install
-
Navigate to the project directory:
cd /path/to/your/project
-
Run tests with pytest:
pytest tests/
The PageManager
dynamically initializes and provides access to different page objects. It uses a dictionary to store page instances and initializes them on demand.
page
: The browser page instance.playwright_page
: ThePlaywrightPage
instance.example_page
: TheExamplePage
instance.
from pages.page_manager import PageManager
def test_playwright(browser):
manager = PageManager(browser)
manager.playwright_page.open()
manager.playwright_page.get_started_button.click()
assert manager.page.title() == "Getting Started · Playwright"
manager.close()