Skip to content

marcoveraz/playwright-typescript-framework

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

36 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🎭 Playwright Automation Framework

Playwright TypeScript Status

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

Marco AdΓ‘n Vera Zboralski
Senior QA Automation Engineer

LinkedIn


πŸ’‘ Overview

This project demonstrates a scalable UI automation framework built with Playwright and TypeScript.

It follows real-world best practices such as Page Object Model (POM), multi-environment configuration, and reusable components to ensure maintainability and reliability.


πŸš€ Framework Design

This project follows a scalable and maintainable automation architecture:

  • βœ… Page Object Model (POM)
  • βœ… Separation of concerns (tests, pages, models, utils)
  • βœ… Dynamic DOM handling to avoid fragile locators
  • βœ… Multi-environment support (dev, qa, stage, prod)
  • βœ… Reusable utility classes

πŸ“ Project Structure

project-root/
│── .github/                 # GitHub workflows, PR templates, CODEOWNERS
│── data/                    # Test data files
β”‚
│── src/
β”‚   β”œβ”€β”€ api/
β”‚   β”‚   β”œβ”€β”€ clients/
β”‚   β”‚   β”‚   └── jsonplaceholder/   # API client classes
β”‚   β”‚   β”œβ”€β”€ fixtures/              # API fixtures
β”‚   β”‚   β”œβ”€β”€ models/
β”‚   β”‚   β”‚   └── jsonplaceholder/   # API data models/interfaces
β”‚   β”‚   β”œβ”€β”€ payloads/
β”‚   β”‚   β”‚   └── jsonplaceholder/   # API request payload builders
β”‚   β”‚   β”œβ”€β”€ utils/                 # API-specific utilities
β”‚   β”‚   └── base.api.ts            # Base API functionality
β”‚   β”‚
β”‚   β”œβ”€β”€ config/
β”‚   β”‚   └── saucedemo/             # Environment/configuration files
β”‚   β”‚
β”‚   β”œβ”€β”€ fixtures/
β”‚   β”‚   └── saucedemo/             # Playwright UI fixtures
β”‚   β”‚
β”‚   β”œβ”€β”€ models/                    # Shared UI/domain models
β”‚   β”‚
β”‚   β”œβ”€β”€ pages/
β”‚   β”‚   └── saucedemo/             # Page Object Model classes
β”‚   β”‚
β”‚   └── utils/                     # Shared utilities and helpers
β”‚
│── tests/
β”‚   β”œβ”€β”€ api/
β”‚   β”‚   └── jsonplaceholder/       # API test specs
β”‚   └── ui/
β”‚       └── saucedemo/             # UI test specs
β”‚
│── test-results/                  # Test execution artifacts
│── playwright-report/             # Playwright HTML reports
│── allure-results/                # Allure raw results
│── allure-report/                 # Allure generated reports
β”‚
│── .gitignore
│── .prettierrc
│── package.json
│── package-lock.json
│── playwright.config.ts
│── README.md

πŸ§ͺ Test Strategy

  • πŸ”„ End-to-End flows (login, checkout)
  • 🎲 Dynamic product selection using randomization
  • βœ… Validation across UI layers
  • πŸ“ BDD-style comments (Given / When / Then)

βš™οΈ Features

  • 🌐 Multi-environment execution
  • 🎲 Randomized test execution
  • πŸ” Product validation across pages
  • πŸ› οΈ Utilities for random data, waits, and calculations
  • 🎬 Playwright features:
    • Video recording
    • Trace viewer
    • Screenshots on failure

πŸ“¦ Installation

# Clone the repository
git clone <repository-url>

# Navigate to project directory
cd playwright-automation-framework

# Install dependencies
npm install

# Install Playwright browsers
npx playwright install

▢️ Running Tests

Basic Commands

# Run all tests
npx playwright test

# Run a specific test file
npx playwright test tests/saucedemo/login-page.spec.ts

# Run tests by name
npx playwright test -g "login"

# Run in headed mode (visible browser)
npx playwright test --headed

# Run with specific number of workers
npx playwright test --workers=4

Debug Mode

# Run in debug mode
npx playwright test --debug

# Run with verbose output
npx playwright test --reporter=list

🌎 Running Tests by Environment

This framework supports multiple environments using the ENV variable.

Available environments:

  • dev (default)
  • qa
  • stage
  • prod

Windows (Command Prompt)

# Set environment and run all tests
set ENV=qa && npx playwright test

# Set environment and run specific test name
set ENV=qa && npx playwright test -g "checkout"

# Set environment and run specific file
set ENV=qa && npx playwright test tests/saucedemo/login-page.spec.ts

Windows (PowerShell)

# Set environment and run tests
$env:ENV="qa"; npx playwright test

# Run specific test
$env:ENV="stage"; npx playwright test -g "checkout"

Mac / Linux

# Run all tests in QA environment
ENV=qa npx playwright test

# Run specific test in staging
ENV=stage npx playwright test -g "checkout"

# Run specific file in production
ENV=prod npx playwright test tests/saucedemo/checkout.spec.ts

πŸ“¦ NPM Scripts

Common scripts are defined in package.json.

Examples:

npm run test
npm run test:dev
npm run test:qa
npm run test:stage
npm run test:prod
npm run test:headed
npm run report:playwright

Environment-specific scripts use cross-env to support Windows, macOS, Linux, and CI/CD environments.

πŸ“Š Reports & Artifacts

View HTML Report

npx playwright show-report

Artifacts Location

test-results/
β”œβ”€β”€ videos/ # .webm video recordings
β”œβ”€β”€ traces/ # Playwright trace files
└── screenshots/ # Failure screenshots

View Trace

# Open trace viewer
npx playwright show-trace test-results/traces/trace.zip

🎯 Purpose

  • πŸ§ͺ Demonstrate automation framework design
  • πŸ’» Practice Playwright + TypeScript
  • πŸ“‹ Showcase testing best practices
  • πŸ“‚ Serve as a portfolio project

🀝 Contributing

Contributions are welcome! This project is intended to grow with additional real-world test scenarios.

You can:

  • πŸ§ͺ Add new test flows
  • πŸ”¨ Improve existing tests
  • βœ… Enhance validations
  • πŸ’‘ Suggest improvements

🧠 Notes

  • 🎯 Uses dynamic locators to avoid fragile selectors
  • πŸ—οΈ Focus on maintainability and scalability
  • 🌐 Designed to simulate real-world automation scenarios
  • πŸ“š Follows testing best practices and design patterns

πŸ“„ License

This project is open source and available under the MIT License.


πŸ“ž Contact

Marco AdΓ‘n Vera Zboralski πŸ”— LinkedIn

About

Scalable UI automation framework built with Playwright and TypeScript using POM and multi-environment support

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors