Skip to content

1alextest/playwright-bdd

Repository files navigation

JDXP Test Automation - Playwright BDD

This project provides end-to-end test automation for the JDXP (Jamaica Digital Exchange Platform) using Playwright with BDD (Behavior Driven Development) approach.

πŸ—οΈ Architecture

Modular Structure

  • Isolated Modules: Each test area (membership, third-party-accreditation) is completely separate
  • Page Object Model: Enhanced page objects with your existing locator entity approach
  • Entity-Aware Testing: Automatic handling of local vs foreign entity differences
  • Fixtures: Dependency injection for clean, reusable test code

Directory Structure

jdxp-test-automation-playwright-bdd/
β”œβ”€β”€ test/
β”‚   └── Modules/
β”‚       β”œβ”€β”€ membership/                    # Membership module (isolated)
β”‚       β”‚   β”œβ”€β”€ config/
β”‚       β”‚   β”‚   β”œβ”€β”€ entity-types.ts       # Entity type definitions
β”‚       β”‚   β”‚   └── locators.config.ts    # Your locator entity approach
β”‚       β”‚   β”œβ”€β”€ features/                 # Gherkin feature files
β”‚       β”‚   β”œβ”€β”€ fixtures/                 # Playwright BDD fixtures
β”‚       β”‚   β”œβ”€β”€ pages/                    # Page Object Models
β”‚       β”‚   β”œβ”€β”€ steps/                    # Step definitions
β”‚       β”‚   └── playwright.config.ts     # Module-specific config
β”‚       β”‚
β”‚       └── third-party-accreditation/    # Future module (isolated)
β”‚
β”œβ”€β”€ test-results/                         # Test outputs
β”œβ”€β”€ .generated/                           # Auto-generated test files
└── package.json

πŸš€ Getting Started

1. Install Dependencies

npm install

2. Install Playwright Browsers

npm run test:install

3. Run Tests

Membership Module

# Generate BDD tests and run membership module
npm run bdd:membership

# Run on different environments
npm run bdd:membership:dev     # Development environment
npm run bdd:membership:qa      # QA environment
npm run bdd:membership:sandbox # Sandbox environment

# Run with different modes
npm run bdd:membership:headed   # With browser UI
npm run bdd:membership:headless # Headless mode

Future Modules

# Third-party accreditation (when implemented)
npm run bdd:accreditation
npm run bdd:accreditation:qa

# Run all modules
npm run bdd:all

🎯 Key Features

1. Entity-Aware Testing

Tests automatically adapt to local vs foreign entities using tags:

@local-entity
Scenario: Local entity registration
  # Uses local entity locators and flow

@foreign-entity  
Scenario: Foreign entity registration
  # Uses foreign entity locators and flow

2. Locator Entity Approach

Your existing locator configuration is enhanced for Playwright BDD:

// Automatic locator selection based on entity type
const memberDetailsPage = new MemberDetailsPage(page, entityType);
await memberDetailsPage.fillCompanyTRN("123456789"); // Uses correct locator

3. Workflow-Focused Page Objects

Page objects provide both granular and workflow methods:

// Granular control
await memberDetailsPage.fillCompanyTRN("123456789");
await memberDetailsPage.fillBranchNumber("001");

// Workflow methods
await memberDetailsPage.fillBasicCompanyInfo(companyData);
await memberDetailsPage.completeForm(fullData);

4. Fixtures for Clean Tests

Automatic dependency injection:

// Step definitions get pre-configured page objects
Given('I am on the member details page', async ({ memberDetailsPage }) => {
  await memberDetailsPage.goto(); // Already configured for correct entity type
});

πŸ§ͺ Writing Tests

1. Feature Files

Write business-readable scenarios in features/ directories:

Feature: Member Details Registration
  @local-entity
  Scenario: Complete local entity registration
    Given I am on the member details page
    When I complete the member details form
    Then the form should be submitted successfully

2. Step Definitions

Implement steps using fixtures in steps/ directories:

When('I complete the member details form', async ({ memberDetailsPage, entityType }) => {
  console.log(`Completing form for ${entityType} entity`);
  await memberDetailsPage.completeForm(testData);
});

3. Page Objects

Create page objects in pages/ directories using your locator entity approach:

export class MemberDetailsPage extends BasePage {
  private locators = getPageLocators('memberDetails', this.entityType);
  
  async fillCompanyTRN(trn: string) {
    await this.fillInput(this.locators.companyTRN, trn);
  }
}

πŸ”§ Configuration

Environment URLs

Set via environment variables or npm scripts:

  • Development: https://jdxp.nginxdev.egovja.com
  • QA: https://jdxp.appsqa.egovja.com
  • Sandbox: https://jdxp.appsandbox.egovja.com
  • Pre-prod: https://jdxp.appspreprod.egovja.com

Browser Configuration

Each module can configure its own browsers and settings in playwright.config.ts.

πŸ“Š Reporting

HTML Reports

npm run test:report

Test Results

  • HTML Report: test-results/membership-playwright-report/
  • JSON Results: test-results/membership-results.json
  • JUnit XML: test-results/membership-results.xml

πŸ› Debugging

Debug Mode

npm run test:debug

UI Mode

npm run test:ui

Screenshots

Automatic screenshots on failure, stored in test-results/screenshots/

πŸ”„ Adding New Modules

  1. Create new module directory: test/Modules/new-module/
  2. Copy structure from membership module
  3. Update locators, pages, and features for new module
  4. Add npm scripts in package.json
  5. Create module-specific playwright.config.ts

🎯 Benefits

  • βœ… Isolated Modules: One module failure doesn't affect others
  • βœ… Entity-Aware: Automatic local/foreign entity handling
  • βœ… Maintainable: Your existing locator entity approach preserved
  • βœ… Scalable: Easy to add new modules and tests
  • βœ… Reliable: Playwright's robust automation
  • βœ… Fast: Parallel execution and efficient test runs

πŸ“š Documentation

Complete Documentation Suite

Key Documentation Highlights

  • Architecture Patterns - Modular design, entity-aware testing, locator entity pattern
  • Development Workflows - Adding modules, pages, entity types, and test scenarios
  • Troubleshooting Guide - Common issues and solutions
  • Best Practices - Code organization, testing strategies, and maintenance
  • Extension Guide - How to scale and extend the framework

Quick Links

This architecture provides a robust, scalable foundation for comprehensive test automation while maintaining the flexibility to adapt to changing business requirements.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors