PlaywrightPomGenerator 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet tool install --global PlaywrightPomGenerator --version 1.0.0
                    
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest
                    
if you are setting up this repo
dotnet tool install --local PlaywrightPomGenerator --version 1.0.0
                    
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=PlaywrightPomGenerator&version=1.0.0
                    
nuke :add-package PlaywrightPomGenerator --version 1.0.0
                    

Playwright POM Generator (ppg)

A .NET CLI tool that automatically generates Playwright Page Object Model (POM) tests for Angular applications.

Features

  • ๐ŸŽฏ Automatic Angular Analysis - Scans Angular workspaces and applications to detect components
  • ๐Ÿ“„ Page Object Generation - Creates type-safe TypeScript page objects with locators
  • ๐Ÿงช Test Scaffolding - Generates Playwright test specs with fixture integration
  • ๐Ÿ”Œ SignalR Mock Support - Generates RxJS-based SignalR mock fixtures for real-time testing
  • โš™๏ธ Configurable Output - Customizable file headers and test file suffixes
  • ๐Ÿ› ๏ธ CI/CD Ready - Command-line interface for easy automation

Installation

Install as a global .NET tool:

dotnet tool install -g PlaywrightPomGenerator

Usage

Generate tests for an Angular application

ppg app /path/to/angular-app -o /output/directory

Generate tests for an Angular workspace

ppg workspace /path/to/workspace -o /output/directory

# For a specific project within the workspace
ppg workspace /path/to/workspace -o /output/directory -p my-project

Generate specific artifacts only

ppg artifacts /path/to/angular-app --all
ppg artifacts /path/to/angular-app --fixtures --page-objects
ppg artifacts /path/to/angular-app --selectors --configs

Generate SignalR mock fixture

ppg signalr-mock /output/directory

Global Options

# Custom file header (supports placeholders: {FileName}, {GeneratedDate}, {ToolVersion})
ppg app /path/to/app -o /output --header "// Generated by MyTool - {FileName}"

# Custom test file suffix (default: spec)
ppg app /path/to/app -o /output --test-suffix test  # Creates *.test.ts instead of *.spec.ts

Generated Output

The tool generates a complete Playwright test structure:

output/
โ”œโ”€โ”€ playwright.config.ts    # Playwright configuration
โ”œโ”€โ”€ fixtures.ts             # Test fixtures with page objects
โ”œโ”€โ”€ helpers.ts              # Utility functions
โ”œโ”€โ”€ signalr-mock.fixture.ts # SignalR mock (if requested)
โ”œโ”€โ”€ pages/
โ”‚   โ”œโ”€โ”€ home.page.ts        # Page object classes
โ”‚   โ””โ”€โ”€ login.page.ts
โ”œโ”€โ”€ selectors/
โ”‚   โ”œโ”€โ”€ home.selectors.ts   # Selector constants
โ”‚   โ””โ”€โ”€ login.selectors.ts
โ””โ”€โ”€ tests/
    โ”œโ”€โ”€ home.spec.ts        # Test specs
    โ””โ”€โ”€ login.spec.ts

Example Generated Page Object

import { Page, Locator } from '@playwright/test';

export class LoginPage {
  readonly page: Page;
  readonly usernameInput: Locator;
  readonly passwordInput: Locator;
  readonly submitButton: Locator;

  constructor(page: Page) {
    this.page = page;
    this.usernameInput = page.locator("[formControlName='username']");
    this.passwordInput = page.locator("[formControlName='password']");
    this.submitButton = page.getByRole('button', { name: 'Login' });
  }

  async fillUsernameInput(value: string): Promise<void> {
    await this.usernameInput.fill(value);
  }

  async fillPasswordInput(value: string): Promise<void> {
    await this.passwordInput.fill(value);
  }

  async clickSubmitButton(): Promise<void> {
    await this.submitButton.click();
  }

  async waitForLoad(): Promise<void> {
    await this.page.waitForSelector('app-login');
  }
}

Configuration

appsettings.json

Place an appsettings.json in your working directory:

{
  "Generator": {
    "FileHeader": "// Custom header for {FileName}",
    "TestFileSuffix": "spec",
    "ToolVersion": "1.0.0",
    "OutputDirectoryName": "e2e",
    "GenerateJsDocComments": true,
    "DefaultTimeout": 30000,
    "BaseUrlPlaceholder": "http://localhost:4200"
  }
}

Environment Variables

Use the POMGEN_ prefix:

export POMGEN_Generator__FileHeader="// My Header"
export POMGEN_Generator__TestFileSuffix="test"

Requirements

  • .NET 8.0 SDK or later
  • Angular application or workspace

Building from Source

git clone https://github.com/anthropics/PlaywrightPomGenerator
cd PlaywrightPomGenerator
dotnet build
dotnet test

Creating the NuGet Package

dotnet pack src/PlaywrightPomGenerator.Cli -c Release

Installing Locally

dotnet tool install -g --add-source ./src/PlaywrightPomGenerator.Cli/nupkg PlaywrightPomGenerator

License

MIT License - see LICENSE file for details.

Contributing

Contributions are welcome! Please open an issue or submit a pull request.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

Version Downloads Last Updated
1.5.0 98 2/9/2026
1.4.0 96 2/5/2026
1.3.2 89 2/4/2026
1.3.1 94 2/4/2026
1.3.0 92 2/4/2026
1.2.0 95 2/4/2026
1.1.0 89 2/4/2026
1.0.0 93 2/4/2026