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.
- β 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.
| 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 |
- .NET 8+ SDK
- IDE: VS Code, Visual Studio, or JetBrains Rider
- Allure CLI (for generating reports)
git clone https://github.com/Suban5/PlaywrightReqnrollPOM.git
cd PlaywrightReqnrollPOMOption A: Using Homebrew (macOS/Linux)
brew install allureOption B: Using npm
npm install -g allure-commandlineOption C: Using Scoop (Windows)
scoop install allureVerify installation:
allure --version# Note: need to be inside project folder
dotnet restore
dotnet build
pwsh bin/Debug/net8.0/playwright.ps1 installRun all tests:
dotnet testRun specific tests by tag:
dotnet test --filter "TestCategory=web"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-reportUsing VS Code Tasks (Alternative):
- Press
Cmd+Shift+P(macOS) orCtrl+Shift+P(Windows/Linux) - Select "Tasks: Run Task"
- Choose "Test + Report (Full Flow)"
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
β
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
- 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
Screenshots are automatically captured on step failures and attached to the Allure report. The AllureReportHooks.cs handles this automatically using the [AfterStep] hook.
- 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.
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 pageCreate 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();
}
}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);
}
}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"
Contributions are welcome! Please open issues or submit pull requests for improvements, bug fixes, or new features.
Happy Testing! π¦