Skip to content

Suban5/PlaywrightReqnrollPOM

Repository files navigation

PlaywrightReqnrollPOM πŸš€

A Modern Automated Web Testing Framework with Playwright, Reqnroll & POM in C#

A robust, scalable, and maintainable web automation testing framework that combines the power of:

  • Playwright – Fast, reliable, and cross-browser automation.
  • Reqnroll (the next generation of SpecFlow) – Behavior-Driven Development (BDD) for business-readable tests.
  • Page Object Model (POM) – Clean separation between test logic and UI interactions for maintainability.

✨ Key Features

  • βœ… Cross-browser testing: Run tests on Chromium, Firefox, and WebKit using Playwright.
  • βœ… BDD with Gherkin: Write human-readable scenarios in plain English with Reqnroll.
  • βœ… Page Object Model (POM): Maintainable and reusable UI automation code.
  • βœ… Extensible & Scalable: Easily add new tests or adapt to UI changes.
  • βœ… Rich Reporting: Integrated with Allure Reports for beautiful, interactive HTML test reports with screenshots.
  • βœ… CI/CD Ready: Includes GitHub Actions workflow for automated build validation.

πŸ› οΈ Tech Stack

Category Tools/Libraries
Test Automation Playwright (.NET)
BDD Framework Reqnroll
Language C# (.NET 8+)
Design Pattern Page Object Model (POM)
Reporting Allure Reports
Test Runner NUnit 4
CI/CD GitHub Actions
Build Tool dotnet CLI

πŸš€ Getting Started

1. Prerequisites

2. Clone the Repository

git clone https://github.com/Suban5/PlaywrightReqnrollPOM.git
cd PlaywrightReqnrollPOM

3. Install Allure CLI

Option A: Using Homebrew (macOS/Linux)

brew install allure

Option B: Using npm

npm install -g allure-commandline

Option C: Using Scoop (Windows)

scoop install allure

Verify installation:

allure --version

4. Install Dependencies & Browsers

# Note: need to be inside project folder
dotnet restore
dotnet build
pwsh bin/Debug/net8.0/playwright.ps1 install

5. Run Tests

Run all tests:

dotnet test

Run specific tests by tag:

dotnet test --filter "TestCategory=web"

6. Generate Allure Report

After running tests, generate and view the interactive Allure report:

# Generate and open report (recommended)
allure serve PlaywrightReqnrollFramework/bin/Debug/net8.0/allure-results/

# OR generate to specific folder
allure generate PlaywrightReqnrollFramework/bin/Debug/net8.0/allure-results/ -o allure-report --clean
allure open allure-report

Using VS Code Tasks (Alternative):

  • Press Cmd+Shift+P (macOS) or Ctrl+Shift+P (Windows/Linux)
  • Select "Tasks: Run Task"
  • Choose "Test + Report (Full Flow)"

πŸ“‚ Project Structure

PlaywrightReqnrollFramework/
β”œβ”€β”€ Features/                  # Gherkin feature files (.feature)
β”‚   β”œβ”€β”€ Login.feature
β”‚   β”œβ”€β”€ ItemsCheckout.feature
β”‚   └── Calculator.feature
β”œβ”€β”€ Pages/                     # Page Object Model classes
β”‚   β”œβ”€β”€ BasePage.cs
β”‚   β”œβ”€β”€ LoginPage.cs
β”‚   β”œβ”€β”€ InventoryPage.cs
β”‚   β”œβ”€β”€ CheckoutPage.cs
β”‚   └── PageFactory.cs
β”œβ”€β”€ StepDefinitions/           # Step definitions for BDD scenarios
β”‚   β”œβ”€β”€ LoginStepDef.cs
β”‚   β”œβ”€β”€ InventoryStepDef.cs
β”‚   └── BaseSteps.cs
β”œβ”€β”€ Hook/                      # Test lifecycle hooks
β”‚   β”œβ”€β”€ Hooks.cs               # Playwright initialization & cleanup
β”‚   └── AllureReportHooks.cs   # Allure reporting hooks (screenshots)
β”œβ”€β”€ Config/                    # Configuration and settings
β”‚   β”œβ”€β”€ ConfigReader.cs
β”‚   └── TestSettings.cs
β”œβ”€β”€ Driver/                    # Browser driver management
β”‚   └── PlaywrightDriver.cs
β”œβ”€β”€ Helpers/                   # Helper utilities
β”‚   └── AllureReportManager.cs
β”œβ”€β”€ Model/                     # Data models
β”‚   β”œβ”€β”€ ProductItem.cs
β”‚   └── CheckoutDetails.cs
β”œβ”€β”€ TestLogger/                # Custom test loggers
β”‚   └── AllureReportOpenerLogger.cs
β”œβ”€β”€ bin/Debug/net8.0/
β”‚   └── allure-results/        # Allure test results (JSON files)
β”œβ”€β”€ appsettings.json           # Default test configuration
β”œβ”€β”€ ci.appsettings.json        # CI-specific configuration
β”œβ”€β”€ dev.appsettings.json       # Development configuration
β”œβ”€β”€ allureConfig.json          # Allure report configuration
β”œβ”€β”€ reqnroll.json              # Reqnroll BDD configuration
└── PlaywrightReqnrollFramework.csproj

πŸ“Š Allure Reporting

What's Included:

βœ… Beautiful Dashboard - Overview with pass/fail statistics and trend graphs
βœ… Test Suites - Tests organized by feature files
βœ… BDD Scenarios - Given/When/Then steps with execution details
βœ… Screenshots - Automatically captured on test failures
βœ… Timeline - Visual timeline of test execution
βœ… Categories - Failure categorization and analysis
βœ… History - Track test trends over multiple runs
βœ… Environment Info - Display test environment configuration

Report Location:

  • Raw Results: PlaywrightReqnrollFramework/bin/Debug/net8.0/allure-results/
  • Generated Report: Created by Allure CLI in temporary directory or specified output folder
  • CI Artifacts: Reports and screenshots uploaded as build artifacts

Screenshot Capture:

Screenshots are automatically captured on step failures and attached to the Allure report. The AllureReportHooks.cs handles this automatically using the [AfterStep] hook.


πŸ€– Continuous Integration

  • GitHub Actions: Automated build workflow runs on every push and pull request.
  • Build Validation: Ensures the project compiles successfully on both Ubuntu and Windows environments.
  • Status: Test execution and reporting are currently disabled in CI/CD pipeline.

🎯 Writing Tests

1. Create a Feature File

Create a .feature file in the Features/ folder:

@web
Feature: Login Functionality
  
  Scenario: Successful login with valid credentials
    Given I navigate to "https://www.saucedemo.com"
    When I login with username "standard_user" and password "secret_sauce"
    Then I should be redirected to the inventory page

2. Create Page Object

Create a page class in Pages/ folder:

public class LoginPage : BasePage
{
    public LoginPage(IPage page) : base(page) { }
    
    private ILocator UsernameInput => Page.Locator("#user-name");
    private ILocator PasswordInput => Page.Locator("#password");
    private ILocator LoginButton => Page.Locator("#login-button");
    
    public async Task LoginAsync(string username, string password)
    {
        await UsernameInput.FillAsync(username);
        await PasswordInput.FillAsync(password);
        await LoginButton.ClickAsync();
    }
}

3. Implement Step Definitions

Create step definitions in StepDefinitions/ folder:

[Binding]
public class LoginStepDef : BaseSteps
{
    private readonly LoginPage _loginPage;
    
    public LoginStepDef(ScenarioContext scenarioContext) : base(scenarioContext)
    {
        _loginPage = PageFactory.GetLoginPage(Page);
    }
    
    [When(@"I login with username ""(.*)"" and password ""(.*)""")]
    public async Task WhenILoginWithUsernameAndPassword(string username, string password)
    {
        await _loginPage.LoginAsync(username, password);
    }
}

🧹 Clean Allure Results

To clean previous test results before a new run:

rm -rf PlaywrightReqnrollFramework/bin/Debug/net8.0/allure-results/*

Or use the VS Code task: "Clean Allure Results"


🀝 Contributing

Contributions are welcome! Please open issues or submit pull requests for improvements, bug fixes, or new features.


πŸ“š Additional Resources


Happy Testing! 🚦

About

A robust and scalable web automation testing framework built using Playwright, Reqnroll & POM in C#

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published