Enterprise E2E testing framework built with Playwright for .NET and NUnit. Page Object Model architecture, parallel execution, FluentAssertions, and CI/CD integration.
| Suite | Tests | Category |
|---|---|---|
| Login | 5 | smoke |
| Inventory | 5 | regression |
| Checkout | 3 | regression |
| Total | 13 |
git clone https://github.com/mustafaautomation/dotnet-playwright-framework.git
cd dotnet-playwright-framework
# Restore and build
dotnet restore
dotnet build
# Install browsers
pwsh bin/Debug/net8.0/playwright.ps1 install --with-deps chromium
# Run all tests
dotnet test --settings PlaywrightTests.runsettings
# Run smoke tests only
dotnet test --filter "Category=smoke"
# Run regression tests
dotnet test --filter "Category=regression"┌─────────────────────────────────────────┐
│ Test Classes │
│ LoginTests │ InventoryTests │ ... │
├─────────────────────────────────────────┤
│ BaseTest │
│ Page init │ LoginAsStandardUser() │
├─────────────────────────────────────────┤
│ Page Objects │
│ LoginPage │ InventoryPage │ CartPage │
│ CheckoutPage │ BasePage │
├─────────────────────────────────────────┤
│ Utils │
│ TestConfig (env-based) │
├─────────────────────────────────────────┤
│ Playwright .NET │ NUnit │ FluentAssert │
└─────────────────────────────────────────┘
Each page encapsulates selectors and actions:
public class LoginPage : BasePage
{
private ILocator UsernameInput => Page.Locator("[data-test='username']");
public async Task Login(string username, string password)
{
await UsernameInput.FillAsync(username);
await PasswordInput.FillAsync(password);
await LoginButton.ClickAsync();
}
}Tests run in parallel by default (4 workers). Configure in PlaywrightTests.runsettings:
<NUnit>
<NumberOfTestWorkers>4</NumberOfTestWorkers>
</NUnit>Each test class gets [Parallelizable(ParallelScope.Self)] for thread safety.
docker build -t pw-dotnet .
docker run --rm pw-dotnet
docker run --rm pw-dotnet --filter "Category=smoke"dotnet-playwright-framework/
├── Pages/
│ ├── BasePage.cs # Base with screenshot, URL helpers
│ ├── LoginPage.cs # Login form interactions
│ ├── InventoryPage.cs # Product list, cart, sorting
│ ├── CartPage.cs # Cart operations
│ └── CheckoutPage.cs # Checkout form and validation
├── Tests/
│ ├── BaseTest.cs # NUnit setup, page initialization
│ ├── Auth/LoginTests.cs # 5 login scenarios
│ ├── Inventory/InventoryTests.cs # 5 inventory scenarios
│ └── Checkout/CheckoutTests.cs # 3 checkout scenarios
├── Utils/
│ └── TestConfig.cs # Environment-based configuration
├── PlaywrightTests.csproj # .NET 8 project file
├── PlaywrightTests.runsettings # Playwright + NUnit config
├── Dockerfile
└── .github/workflows/e2e-tests.yml
| Tool | Purpose |
|---|---|
| Playwright .NET 1.49 | Browser automation |
| NUnit 4.3 | Test runner with parallel support |
| FluentAssertions 7.0 | Readable C# assertions |
| .NET 8 | Runtime |
| Docker | Containerized execution |
MIT
Built by Quvantic