How jaydipmaniya/ui-automation-selenium-python-pytest works
Project Type and Purpose
• This repository is a UI test automation framework written in Python using Selenium WebDriver and Pytest.
• It implements the Page Object Model (POM) design pattern, organizes locators, test data, and utility libraries, and generates logs/reports.
File Structure Analysis
• Top-level:
• README.md – framework description & usage
• requirements.txt – Python dependencies
• conftest.py – pytest fixtures (e.g. WebDriver setup/teardown)
• tests/ – test suite (one end-to-end test)
• utils/ (the core framework code)
• data/ – test data (LOGIN_EMAIL, LOGIN_PASSWORD)
• locators/ – Page Object locators for elements
• pages/ – Page classes encapsulating UI interactions
• lib/ – utility modules (LoggerUtils, WebDriver management)
README Insights
• Uses WebDriver Manager to auto-install browser drivers
• Default browser: Chrome; optional Firefox via CLI flag
• Generates timestamped log files and an optional HTML report
Main Components
a. Test Runner & Entry Point
• pytest CLI → conftest.py fixtures → tests/test_amazon_login_search_add_product_to_cart.py
b. Page Object Layer
• BasePage.py (common methods: click, send_keys, wait)
• AmazonAddProductToCart.py (high-level user flows)
c. Locator Layer
• amazon_add_product_to_cart.py (By-locators keyed to page elements)
d. Test Data Layer
• amazon_add_product_to_cart_data.py (constants for credentials, search terms)
e. Utility Layer
• LoggerUtils.py (configures and writes log files)
• WebDriver setup (in conftest.py using WebDriverManager)
f. External Systems
• Browser (Chrome or Firefox)
• Amazon website (System Under Test)
g. Output Artifacts
• log-<timestamp>.log
• pytest HTML report
Relationships & Data Flow
1. pytest CLI invocation loads conftest fixtures → Instantiates WebDriver
2. Test case calls Page Object methods
3. Page Objects use Locator definitions + Data inputs → Selenium WebDriver API calls
4. Browser executes actions against Amazon UI
5. Responses/status captured, returned to test
6. Utilities log each step and capture screenshots on failure
7. After test suite completes, pytest generates HTML report
Architectural Patterns & Design Principles
• Page Object Model (separation of UI structure from test logic)
• Layered framework: Tests → Pages → Locators/Data → Utils
• Dependency inversion: tests depend on abstractions (Page classes), not raw Selenium calls
• Reusability: common logging and driver management extracted to utils/lib