A comprehensive C# test automation framework demonstrating modern automation engineering practices including Selenium WebDriver UI testing, REST API testing, cross-browser compatibility, containerization, and CI/CD integration.
- Cross-Browser Testing: Chrome, Firefox, Edge support with automatic driver management
- API Testing: RESTful API testing with authentication, validation, and error handling
- Page Object Model: Scalable UI test architecture with reusable page components
- Parallel Execution: Concurrent test execution for faster feedback
- CI/CD Integration: GitHub Actions pipeline with comprehensive reporting
- Docker Support: Containerized test execution for consistent environments
- Structured Logging: Detailed test execution logs with Serilog
- Screenshot Capture: Automatic screenshots on test failures
- Test Reporting: Multiple output formats (TRX, JSON, HTML)
- .NET 8: Modern C# development platform
- NUnit: Testing framework with rich assertion library
- Selenium WebDriver: Browser automation and UI testing
- HttpClient: REST API testing and validation
- Docker: Containerized test execution
- GitHub Actions: CI/CD pipeline automation
- Serilog: Structured logging and diagnostics
TestAutomationFramework/
βββ TestFramework/ # Core framework components
β βββ DriverFactory.cs # WebDriver factory with cross-browser support
β βββ BasePage.cs # Base page object model class
β βββ ApiClient.cs # REST API client with authentication
βββ UI.AutomationTests/ # User interface test suite
β βββ Pages/ # Page object model implementations
β β βββ GoogleHomePage.cs # Google home page interactions
β β βββ GoogleSearchResultsPage.cs # Search results page
β βββ Tests/ # UI test implementations
β βββ GoogleSearchTests.cs # Search functionality tests
βββ API.AutomationTests/ # API test suite
β βββ Tests/
β βββ JsonPlaceholderApiTests.cs # REST API CRUD tests
βββ .github/workflows/ # CI/CD pipeline definitions
β βββ test-automation.yml # GitHub Actions workflow
βββ Dockerfile # Container configuration
βββ appsettings.json # Framework configuration
βββ README.md # This documentation
- .NET 8 SDK
- Chrome/Firefox/Edge browsers
- Docker (optional for containerized execution)
- Git
-
Create Solution Structure
# Create main directory mkdir TestAutomationFramework cd TestAutomationFramework # Create solution dotnet new sln -n "TestAutomationFramework" # Create projects dotnet new classlib -n "TestFramework" -f net8.0 dotnet new nunit -n "UI.AutomationTests" -f net8.0 dotnet new nunit -n "API.AutomationTests" -f net8.0 # Add projects to solution dotnet sln add TestFramework/TestFramework.csproj dotnet sln add UI.AutomationTests/UI.AutomationTests.csproj dotnet sln add API.AutomationTests/API.AutomationTests.csproj
-
Install NuGet Packages
# Framework packages cd TestFramework dotnet add package Selenium.WebDriver dotnet add package Selenium.WebDriver.ChromeDriver dotnet add package Selenium.Support dotnet add package DotNetSeleniumExtras.WaitHelpers dotnet add package Microsoft.Extensions.Configuration.Json dotnet add package Serilog dotnet add package Newtonsoft.Json # Add project references cd ../UI.AutomationTests dotnet add reference ../TestFramework/TestFramework.csproj cd ../API.AutomationTests dotnet add reference ../TestFramework/TestFramework.csproj
-
Build Solution
cd .. dotnet build --configuration Release
dotnet test --configuration Release# API tests only
dotnet test API.AutomationTests/API.AutomationTests.csproj
# UI tests only
dotnet test UI.AutomationTests/UI.AutomationTests.csproj# Chrome (default)
$env:BROWSER="Chrome"
dotnet test UI.AutomationTests/UI.AutomationTests.csproj
# Firefox
$env:BROWSER="Firefox"
dotnet test UI.AutomationTests/UI.AutomationTests.csproj
# Edge
$env:BROWSER="Edge"
dotnet test UI.AutomationTests/UI.AutomationTests.csproj# Smoke tests only
dotnet test --filter "Category=Smoke"
# Performance tests
dotnet test --filter "Category=Performance"
# Cross-browser tests
dotnet test --filter "Category=Cross-Browser"# Build Docker image
docker build -t test-automation-framework:latest .
# Run tests in container
docker run --rm test-automation-framework:latest
# Run with volume mounts for results
docker run --rm \
-v ${PWD}/TestResults:/app/TestResults \
-v ${PWD}/logs:/app/logs \
-v ${PWD}/Screenshots:/app/Screenshots \
test-automation-framework:latest- TRX Files: Visual Studio test result format
- Coverage Reports: Code coverage analysis
- Screenshots: Failure evidence for UI tests
- Logs: Detailed execution traces
- HTML Reports: Human-readable test summaries
# View test results
Start-Process ./TestResults/test-results.trx
# Open log files
Get-Content ./logs/test-log-*.txt | Out-GridView
# Browse screenshots
Invoke-Item ./Screenshots/Modify appsettings.json to customize browser behavior:
{
"BrowserSettings": {
"Chrome": {
"Arguments": [
"--no-sandbox",
"--disable-dev-shm-usage",
"--window-size=1920,1080"
]
}
}
}Configure different environments for test execution:
{
"Environment": {
"CurrentEnvironment": "Development",
"Environments": {
"Development": {
"BaseUrl": "https://dev.example.com"
},
"Staging": {
"BaseUrl": "https://staging.example.com"
}
}
}
}- Multi-Browser Testing: Parallel execution across Chrome and Firefox
- API Testing: Comprehensive REST API validation
- Container Testing: Docker-based test execution
- Artifact Collection: Test results, logs, and screenshots
- Scheduled Runs: Daily regression testing
- Performance Monitoring: Baseline performance validation
- Push to main/develop branches
- Pull requests to main
- Daily scheduled runs (6 AM UTC)
- Manual execution with
[perf]commit message
- Navigate to GitHub repository
- Click "Actions" tab
- Select latest workflow run
- Download artifacts for detailed results
Quick validation of core functionality
[Test]
[Category("Smoke")]
public void GoogleHomePage_ShouldLoadSuccessfully()Comprehensive feature testing
[Test]
[Category("Functional")]
[TestCase("Selenium WebDriver")]
public void GoogleSearch_ShouldReturnRelevantResults(string searchTerm)Response time and load validation
[Test]
[Category("Performance")]
public void GoogleSearch_ShouldCompleteWithinTimeLimit()Multi-browser compatibility validation
[Test]
[Category("Cross-Browser")]
public void GoogleSearch_ShouldWorkAcrossBrowsers()# Update Chrome driver
dotnet add package Selenium.WebDriver.ChromeDriver --prerelease
# Check Chrome version compatibility
chrome --version# Test API connectivity
curl https://jsonplaceholder.typicode.com/posts/1
# Check proxy settings
$env:HTTP_PROXY=""
$env:HTTPS_PROXY=""# Set execution policy for scripts
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser- Encapsulate page interactions in dedicated classes
- Use meaningful element locators
- Implement wait strategies for dynamic content
- Validate both positive and negative scenarios
- Test error handling and edge cases
- Verify response schemas and data integrity
- Keep tests atomic and independent
- Use descriptive test names and categories
- Implement proper setup and teardown
- Run tests in multiple environments
- Collect comprehensive artifacts
- Set up notifications for failures
- Fork the repository
- Create feature branch:
git checkout -b feature/new-test-suite - Commit changes:
git commit -am 'Add new test suite' - Push to branch:
git push origin feature/new-test-suite - Submit pull request
This project is licensed under the MIT License - see the LICENSE file for details.
- Create GitHub issues for bugs and feature requests
- Check existing documentation and troubleshooting guides
- Review CI/CD pipeline logs for execution details
Built with β€οΈ for Quality Engineering
This framework demonstrates modern test automation practices suitable for enterprise-level applications and serves as a foundation for scalable, maintainable test automation solutions.