A robust and scalable test automation framework built with Playwright for .NET, featuring comprehensive reporting, logging, and configuration management.
- Cross-browser Testing: Support for Chromium, Firefox, and WebKit
- Parallel Test Execution: MSTest-based parallel test execution
- Rich Reporting: HTML reports with videos, traces, and logs
- Configuration Management: Environment-based configuration
- Logging: Comprehensive logging with different levels
- Page Object Model: Structured and maintainable test architecture
- Tracing: Built-in Playwright trace viewer support
- Video Recording: Automatic video recording of test executions
- .NET 9.0 SDK
- Visual Studio 2022 or Visual Studio Code
- PowerShell (for running Playwright installation scripts)
-
Clone the repository:
git clone https://github.com/vrknetha/playwright-dotnet.git cd playwright-dotnet -
Install dependencies:
dotnet restore
-
Install Playwright browsers:
pwsh bin/Debug/net9.0/playwright.ps1 install
-
Build the solution:
dotnet build
-
Run the tests:
dotnet test
├── Infrastructure/
│ ├── Base/ # Base classes for tests and page objects
│ ├── Config/ # Configuration management
│ ├── Reporting/ # Test reporting infrastructure
│ ├── Tracing/ # Playwright tracing setup
│ └── UI/ # UI interaction helpers
├── Pages/ # Page Object Models
├── Tests/ # Test classes
├── TestResults/ # Test execution results
│ └── Reports/ # HTML reports with artifacts
└── appsettings.json # Application configuration
The framework uses appsettings.json for configuration:
{
"TestSettings": {
"Browser": {
"Name": "chromium",
"Headless": false,
"SlowMo": 0,
"Viewport": {
"Width": 1920,
"Height": 1080
}
},
"Trace": {
"Enabled": true,
"Mode": "Always",
"Screenshots": true,
"Snapshots": true,
"Sources": true
}
}
}Example test using the framework:
[TestClass]
public class SampleTest : TestBase
{
[TestMethod]
public async Task NavigationTest()
{
// Arrange
await Page.GotoAsync("https://playwright.dev");
// Act
await Page.ClickAsync("text=Get Started");
// Assert
await Expect(Page).ToHaveURLAsync("**/docs/intro");
}
}After test execution, you can find the following artifacts in the TestResults/Reports directory:
- HTML report (
index.html) - Test videos (
.webmfiles) - Playwright traces (
.zipfiles) - Test logs (
.logfiles)
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.