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! 🚦