DEV Community

Shell QA
Shell QA

Posted on

Structuring a Playwright BDD Automation Framework: Core Architecture & Directory Guide

Organizing a test automation framework cleanly is vital as your test suites scale across multiple applications, platforms, and teams. A modular, maintainable folder structure keeps features, step definitions, page objects, and utilities decoupled and easy to extend.

Here is a comprehensive directory guide and best-practices layout for a BDD-enabled Playwright framework supporting Web UI, API, and Salesforce test automation.

Core Directory Structure

<project-root>/
├── features/
│   ├── API/                   # API_TestCase.feature, JSON_TestData_Examples.feature
│   ├── UI/                    # UI_TestCase.feature
│   └── Salesforce/            # Salesforce_API_Smoke.feature, Salesforce_UI_Login_Smoke.feature
├── step-definitions/
│   ├── API/                   # PlaywrightSteps.js, SalesforceSteps.js
│   ├── UI/                    # Common_UI_Steps.js, LoginSteps.js, RegisterUserSteps.js
│   └── Salesforce/            # SalesforceAPISteps.js, SalesforceSteps.js
├── page-objects/              # PageManager.js, BasePage.js, HomePage.js, LoginPage.js, SalesforceLoginPage.js
├── setup/                     # hooks.js, api-hooks.js, assertions.js, video-recorder.js
├── utils/                     # ApiHelper.js, AppiumHelper.js, ExcelHelper.js, Logger.js
├── test-data/
│   ├── json/                  # testData.json, apiTestData.json
│   └── excel/                 # users.xlsx, products.xlsx, generateSampleData.js
├── reports/
├── test-results/
├── logs/
├── config.js
├── cucumber.config.js
├── playwright.config.js
└── package.json
Enter fullscreen mode Exit fullscreen mode

Key Guidelines for Source Control

What to Commit:

  • Source Files: All feature files (features/), step definitions (step-definitions/), page models (page-objects/), test hooks (setup/), and helpers (utils/).

  • Test Data & Generators: Core JSON fixture files and Excel data generator scripts.

  • Configurations: Environment files, playwright.config.js, cucumber.config.js, and package.json.

What Not to Commit (Add to .gitignore):

  • node_modules/

  • Execution output, logs, and HTML/JSON test reports (reports/, test-results/, logs/)

  • Generated Excel output files created dynamically during runtime execution

Top comments (0)