Manuals / Playwright with Python / Chapter 39

Part 6 · Pro-Level Practices · pro · ~60 min · Chapter 39 of 61

29. Building a Scalable Framework from Scratch

Folder architecture for enterprise-grade projects Past a certain size, a flat tests/ + pages/ structure (Chapter 14) stops being enough. An enterprise-grade layout separates concerns clearly so new contributors can navigate it without a guided tour: project/ ├── tests/ │ ├── smoke/ │ ├── regression/ │ └── modules/ │ ├── test_leave.py │ ├── test_attendance.py │ └── test_payroll.py ├── pages/ │ ├──

Path progress
63%

Step 1 of 6

Folder architecture for enterprise-grade projects

Past a certain size, a flat tests/ + pages/ structure (Chapter 14) stops being enough. An enterprise-grade layout separates concerns clearly so new contributors can navigate it without a guided tour: project/ ├── tests/ │ ├── smoke/ │ ├── regression/ │ └── modules/ │ ├── test_leave.py │ ├── test_attendance.py │ └── test_payroll.py ├── pages/ │ ├── base_page.py │ └── modules/ │ ├── leave_page.py │ └── attendance_page.py ├── utils/ │ ├── api_helpers.py │ ├── data_generators.py │ └── wait_helpers.py ├── config/ │ ├── environments.py │ └── settings.py ├── test_data/ │ └── users.json ├── conftest.py ├── pytest.ini └── requirements.txt Pointers: The organizing principle is "a new engineer should be able to guess where something lives before searching for it." Grouping page objects and tests by feature module (mirroring your actual application's modules — e.g., matching Bizlevate's Leave/Attendance/Payroll structure) rather than by arbitrary file order keeps the mapping between app and test suite obvious.

Folder architecture for enterprise-grade projectsDrag stickies · tap for tips
Study mapDrag stickies · tap for tipsKeep it shortdrag · tap →Name the waitdrag · tap →Scope locatorsdrag · tap →Trace when stuckdrag · tap →One browser firstdrag · tap →Isolate statedrag · tap →Assert the UIdrag · tap →Retry wiselydrag · tap →Seed datadrag · tap →Close the loopdrag · tap →Keep it shortdrag · tap →Name the waitdrag · tap →Scope locatorsdrag · tap →Trace when stuckdrag · tap →One browser firstdrag · tap →Isolate statedrag · tap →Pathwise hackdrag · tap →Page under testdrag · tap →Multi-browserdrag · tap →Automation pathdrag · tap →Tooling nodedrag · tap →
Was this step clear?
Chapter learning outcomes
  • Folder architecture for enterprise-grade projects
  • Utilities/helpers layer
  • Utility function pattern (utils/*.py — convention, not a Playwright API)
  • Config-driven test execution
  • BASE_URL = {

Clear these before you leave

Side quest

29. Building a Scalable Framework from Scratch deliverable

Apply one idea from “Folder architecture for enterprise-grade projects” in a small script or note.