How tamim-cste/books-automation-farman-arefin-tamim works
1. This repository is a test automation framework, not an application: it validates the public site books.toscrape.com using Python, Playwright, and Pytest. The architecture is centered on browser-driven UI tests with a small supporting utility layer and CI workflow.
2. The top-level execution path is: Pytest discovers tests in tests/ → fixtures in conftest.py create browser/test context state → test cases call page objects in pages/ → page objects drive Playwright against the target site. That makes the page layer the main boundary between test intent and browser mechanics.
3. pages/ is the primary UI abstraction layer. base_page.py holds shared browser actions and synchronization behavior, while home_page.py and book_detail_page.py represent the two main screens under test. This keeps selectors and interaction logic out of the test cases.
4. The tests are organized by business scenario, not by technical layer:
- test_01_homepage.py checks homepage integrity
- test_02_book_navigation.py exercises random navigation to detail pages
- test_03_data_consistency.py compares homepage and detail-page book data
- test_04_broken_links.py validates href targets via HTTP
- test_05_image_validation.py checks image attributes across multiple pages
5. There is a clear split between UI validation and HTTP validation. Most scenarios use Playwright in the browser, but the broken-link checks use requests from the utility layer to verify response codes. That means the framework crosses two protocols: DOM/browser interactions and direct network requests.
6. utils/ is the support layer for shared logic and configuration. config.py likely centralizes runtime settings such as headless mode, base URL, and environment-driven defaults; helpers.py contains reusable functions such as price normalization and other cross-test transformations. This prevents duplicate logic in tests and page objects.
7. The suite’s data model is intentionally lightweight. The README mentions a BookCard dataclass, which implies book metadata is passed between page objects and tests as structured data rather than raw selectors/strings. That keeps the data flow explicit: page scrape → data object → assertion.
8. conftest.py is the orchestration boundary for test infrastructure. It is where browser/session fixtures, context isolation, and likely artifact capture hooks are defined. The design choice described in the README is one shared browser per run with fresh contexts per test, which balances speed and isolation.
9. Reporting is a first-class output of the framework. The suite produces pytest HTML output and Allure artifacts, and failure diagnostics include screenshots, videos, and traces. These are not part of test logic, but they are important architectural outputs because the CI pipeline and local debugging depend on them.
10. .github/workflows/playwright.yml is the delivery/automation layer. It installs dependencies, installs Chromium/Playwright, runs the Pytest suite, generates reports, and uploads artifacts. The workflow turns the repository into a repeatable validation pipeline triggered on push, pull request, or manual dispatch.
11. The main external dependency boundary is the target website books.toscrape.com. All UI assertions and data consistency checks depend on that site’s DOM structure and content. The framework is therefore sensitive to site changes, while link validation additionally depends on the availability and SSL behavior of the target endpoints.
12. For an architecture diagram, the key boxes are: CI runner, Pytest test suite, fixture/orchestration layer, page object layer, utility/config layer, Playwright browser context, and external site/HTTP endpoints. The key flows are test discovery and execution, browser interaction, data extraction/comparison, HTTP verification, and artifact/report generation.
Main entry points: pytest.ini Pytest Runner · home_page.py Home Page · book_detail_page.py Book Detail · conftest.py Fixtures
Components 18
CI / Delivery
Automation and artifact publishing
- Playwright CI · Installs dependencies, runs tests, and publishes reports/artifacts
.github/workflows/playwright.yml - Reports · HTML, Allure, screenshots, videos, and traces
Pytest Suite
Test scenarios and orchestration
- Pytest Runner · Discovers and executes the suite
pytest.ini - Fixtures · Browser/session setup, context isolation, and artifact hooks
conftest.py - Homepage Test · Checks homepage integrity
tests/test_01_homepage.py - Navigation Test · Exercises random navigation to book detail pages
tests/test_02_book_navigation.py - Consistency Test · Compares homepage and detail-page book data
tests/test_03_data_consistency.py - Broken Links · Validates href targets with HTTP requests
tests/test_04_broken_links.py - Image Validation · Checks image attributes across multiple pages
tests/test_05_image_validation.py
Browser Flow
Page objects and browser interaction layer
- Base Page · Shared browser actions and synchronization
pages/base_page.py - Home Page · Homepage selectors and interactions
pages/home_page.py - Book Detail · Detail-page selectors and data access
pages/book_detail_page.py - Playwright · Browser context used for UI validation
Support Layer
Shared config, helpers, and data models
External Systems
Target site and network endpoints
- Books Site · books.toscrape.com target for all UI assertions
- HTTP Endpoints · Book and asset URLs checked by link validation
Connections 28
- Playwright CI → Pytest Runner: runs · CI invokes the test runner
- Playwright CI → Reports: uploads · Artifacts and reports are collected in CI
- Pytest Runner → Fixtures: loads · Pytest initializes shared fixtures and hooks
- Pytest Runner → Homepage Test: executes · Suite includes homepage validation
- Pytest Runner → Navigation Test: executes · Suite includes navigation validation
- Pytest Runner → Consistency Test: executes · Suite includes data consistency validation
- Pytest Runner → Broken Links: executes · Suite includes link validation
- Pytest Runner → Image Validation: executes · Suite includes image validation
- Fixtures → Playwright: creates · Fixtures provision browser and fresh contexts
- Fixtures → Reports: captures · Failures emit screenshots, videos, and traces
- Homepage Test → Home Page: uses · Homepage scenario delegates browser actions
- Navigation Test → Home Page: uses · Navigation begins from the homepage abstraction
- Navigation Test → Book Detail: uses · Navigation lands on detail pages
- Consistency Test → Home Page: uses · Scrapes book data from homepage cards
- Consistency Test → Book Detail: uses · Compares homepage data with detail pages
- Broken Links → Helpers: uses · Shared logic supports response checks and transforms
- Image Validation → Helpers: uses · Shared transformations support image assertions
- Home Page → Base Page: inherits · Homepage builds on common browser behavior
- Book Detail → Base Page: inherits · Detail page builds on common browser behavior
- Base Page → Playwright: drives · Common actions execute through Playwright
- Home Page → Books Site: navigates · Homepage automation targets the public site
- Book Detail → Books Site: navigates · Detail-page automation targets the public site
- Home Page → BookCard: returns · Homepage scraping produces structured book data
- Book Detail → BookCard: returns · Detail-page scraping produces structured book data
- Home Page → Config: reads · Page behavior uses shared runtime settings
- Book Detail → Config: reads · Page behavior uses shared runtime settings
- Broken Links → HTTP Endpoints: checks · Broken-link validation verifies URL responses
- Image Validation → Books Site: inspects · Image assertions depend on rendered site content