Welcome to the PlaywrightTestFramework — a scalable, modern UI automation solution built with:
- 💻 .NET 8
- 🔪 Playwright for .NET
- 🐳 Docker
- 🚀 CI via GitHub Actions
- 📦 NuGet Tooling
This framework demonstrates best practices in UI automation using Playwright with C#, designed for clean test architecture, easy CI/CD integration, and Docker-based test execution.
PlaywrightTestFramework/
├── Tests/ # Test classes using NUnit
├── Pages/ # Page Object Models
├── Drivers/ # Browser initialization and test lifecycle
├── Utilities/ # Helpers, constants, config readers
├── Dockerfile # Docker support to run tests in container
├── playwright.docker.yml # GitHub Action to run tests via Docker
├── playwright-ci.yml # GitHub Action for native CI testing
├── PlaywrightTestFramework.csproj # Project file
Tool | Purpose |
---|---|
.NET 8 | Test project runtime |
Playwright | UI automation engine |
NUnit | Test framework |
Docker | Containerized test execution |
GitHub Actions | Continuous Integration & Test Automation |
- .NET 8 SDK
- Node.js (Playwright dependency)
- PowerShell Core
- Docker Desktop (for container support)
# Restore tools and dependencies
dotnet restore
dotnet tool restore
# Build project
dotnet build
# Install browsers
dotnet playwright install
# Run tests
dotnet test --configuration Release
docker build -t playwright-csharp-ui-tests .
docker run --rm playwright-csharp-ui-tests
✔ Dockerfile is configured to install necessary dependencies, build the app, and execute tests inside a container.
Runs tests automatically on push or PR to master
:
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
Manually trigger Docker-based test run:
on:
workflow_dispatch:
Run from GitHub UI ➔ Actions ➔ Select Workflow ➔ Run workflow.
- 🧱 Page Object Model: Test logic separated from UI selectors.
- 🔄 Reusable Hooks: NUnit SetUp/TearDown support for test lifecycle.
- ⚙️ Cross-browser ready: Can run on Chromium, Firefox, WebKit.
- 📦 Docker-ready: Simplifies CI and remote test execution.
- 📊 Scalable for CI/CD: Plug into pipelines seamlessly.
[Test]
public async Task AddAndToggleTodo_ShouldMarkItemCompleted()
{
await Page.GotoAsync("https://example-todo-app.com");
await Page.FillAsync("#new-todo", "Learn Playwright");
await Page.ClickAsync("#add-todo");
await Page.ClickAsync(".todo-item >> text=Learn Playwright");
Assert.True(await Page.IsCheckedAsync(".todo-item.completed"));
}
FROM mcr.microsoft.com/dotnet/sdk:8.0
# Install dependencies required by Playwright browsers
RUN apt-get update && apt-get install -y <browser-deps>
WORKDIR /app
COPY *.csproj ./
RUN dotnet restore
COPY . ./
RUN dotnet build
# Add Playwright tool and install browsers
RUN dotnet tool install --global Microsoft.Playwright.CLI
ENV PATH="${PATH}:/root/.dotnet/tools"
RUN dotnet playwright install
CMD ["dotnet", "test", "--configuration", "Release"]
PRs, feature requests, and ideas are welcome! Feel free to fork and suggest enhancements to improve the test architecture or CI pipeline.
This project is licensed under the MIT License
Johil Angelo 🔗 GitHub Profile 🔗 LinkedIn