Skip to content

ankitaloni369/PlayWrightAutomation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

21 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ Playwright Automation Framework (POM + Excel Data-Driven + CI)

A scalable end-to-end test automation framework built using Playwright with support for data-driven testing using Excel, Page Object Model (POM), and CI/CD integration. Perfect for testing applications with multiple test scenarios and data variations.


🎯 Why This Framework?

This framework solves common automation challenges:

  • Data-Driven Testing: Test the same scenario with multiple data sets (e.g., different user credentials)
  • Maintainability: Page Object Model ensures UI changes only need updates in one place
  • Scalability: Clean folder structure makes adding new tests easy
  • CI/CD Ready: Automated test execution in GitHub Actions

πŸ”₯ Key Features

Feature Description
βœ… Data-driven testing Uses ExcelJS to read test data from Excel files, allowing easy test data management
βœ… Page Object Model (POM) Encapsulates page elements and actions for better code reusability
βœ… Cross-browser testing Supports Chromium, Firefox, and WebKit with same test scripts
βœ… Reusable utilities Excel readers, wait helpers, and common functions in utils/ folder
βœ… HTML Reporting Built-in Playwright HTML reports for easy test result visualization
βœ… CI/CD ready GitHub Actions workflow configured for automated test execution
βœ… Clean architecture Well-organized folder structure for long-term maintainability

πŸ“Έ Test Execution Screenshots

Test Execution Test Results Allure Report
Test Execution Test Results Allure Report
Sample Reports
Sample Test Results
Test Screenshot
AllureTestResults
AllureTestResults

πŸ“‹ Prerequisites

Before you begin, ensure you have the following installed:

  • Node.js (v14 or higher) - Download
  • npm (comes with Node.js) or yarn package manager
  • Git for cloning the repository

⚑ Quick Start Guide

1️⃣ Clone the Repository

git clone https://github.com/ankitaloni369/PlayWrightAutomation.git
cd PlayWrightAutomation

2️⃣ Install Dependencies

npm install

This installs:

Playwright test runner ExcelJS (for Excel data handling) Allure reporter (optional) Other required dependencies

3️⃣ Install Playwright Browsers

npx playwright install

Downloads Chromium, Firefox, and WebKit browsers for testing.

4️⃣ Run Tests

# Run all tests
npx playwright test

# Run specific test file
npx playwright test tests/WebAPITest.spec.js

# Run tests in headed mode (see browser UI)
npx playwright test --headed

# Run tests with specific browser
npx playwright test --project=chromium

πŸ“‚ Project Structure Explained

PlayWrightAutomation/
β”‚
β”œβ”€β”€ tests/                      # Test specifications
β”‚   β”œβ”€β”€ WebAPITest.spec.js      # Example test file
β”‚   └── login.spec.js           # Login test scenarios
β”‚
β”œβ”€β”€ pages/                      # Page Object Models (POM)
β”‚   β”œβ”€β”€ LoginPage.js            # Login page elements & methods
β”‚   β”œβ”€β”€ HomePage.js             # Home page elements & methods
β”‚   └── BasePage.js             # Common page methods (base class)
β”‚
β”œβ”€β”€ utils/                      # Utility/Helper functions
β”‚   β”œβ”€β”€ excelUtils.js           # Excel read/write operations
β”‚   β”œβ”€β”€ waitHelpers.js          # Custom wait functions
β”‚   └── testDataHelper.js       # Test data processing
β”‚
β”œβ”€β”€ test-data/                  # Test data files
β”‚   β”œβ”€β”€ loginData.xlsx          # Excel file with test credentials
β”‚   └── testData.json           # Optional JSON test data
β”‚
β”œβ”€β”€ allure-results/             # Allure test results (generated)
β”œβ”€β”€ test-results/               # Playwright test results
β”œβ”€β”€ playwright-report/          # HTML report location
β”‚
β”œβ”€β”€ playwright.config.js        # Playwright configuration
β”œβ”€β”€ package.json                # Dependencies & scripts
└── .github/workflows/          # GitHub Actions CI/CD
    └── playwright.yml          # CI workflow configuration

πŸ§ͺ Data-Driven Testing Example

| Excel File Structure (test-data/loginData.xlsx) |

Username Password ExpectedResult
user1@example.com Pass123 success
user2@example.com Pass456 success
invalid@example.com wrong failure

Test Implementation

// Import Excel utility
const { getExcelData } = require('../utils/excelUtils');

// Read test data from Excel
const testData = await getExcelData('loginData', 'Sheet1');

// Create tests dynamically for each data row
for (const data of testData) {
    test(`Login Test - ${data.Username}`, async ({ page }) => {
        const loginPage = new LoginPage(page);
        await loginPage.navigate();
        
        const result = await loginPage.login(
            data.Username, 
            data.Password
        );
        
        if (data.ExpectedResult === 'success') {
            await expect(result).toBeTruthy();
        } else {
            await expect(result).toBeFalsy();
        }
    });
}

πŸ“Š Reporting

Generate and View Reports

# After test execution, generate HTML report
npx playwright show-report

# For Allure reporting
npm run allure:generate   # Generate Allure report
npm run allure:open       # Open in browser

Reports show:

  • Passed/Failed test counts
  • Test execution times
  • Screenshots on failure
  • Error stack traces
  • Browser & device information

πŸ”„ CI/CD Integration

GitHub Actions Workflow (.github/workflows/playwright.yml)

name: Playwright Tests
on:
  push:
    branches: [ main, master ]
  pull_request:
    branches: [ main, master ]
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
      - run: npm ci
      - run: npx playwright install --with-deps
      - run: npx playwright test

πŸ› οΈ Custom Scripts

Command Description
npm test Run all tests in headed mode
npm run allure:generate Generate Allure report from results
npm run allure:open Open Allure report in browser

πŸ› Troubleshooting

Issue: Tests fail with "Browser not found"

npx playwright install

Issue: Excel file not found

  • Ensure test-data/ folder exists with Excel files
  • Check file path in excelUtils.js

Issue: Tests timeout

#// Increase timeout in playwright.config.js 
timeout: 60000,  #// 60 seconds

🀝 Contributing

  1. Fork the repository
  2. Create feature branch: git checkout -b feature/amazing-feature
  3. Commit changes: git commit -m 'Add amazing feature'
  4. Push: git push origin feature/amazing-feature
  5. Open Pull Request

πŸ‘©β€πŸ’» Author

Ankit Aloni 
 GitHub: @ankitaloni369

πŸ“š Resources & References

  • Playwright Documentation
  • ExcelJS Documentation
  • Page Object Model Pattern
  • GitHub Actions Documentation

πŸŽ‰ Acknowledgments

  • Playwright team for excellent testing framework
  • Open source community for valuable tools
  • All contributors and users of this framework

⭐ Support

If you find this framework useful, please give it a ⭐ on GitHub!

About

Playwright automation framework with Page Object Model (POM), Excel data-driven testing (ExcelJS), CI/CD using GitHub Actions, and HTML reporting.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors