A comprehensive .NET web application demonstrating Playwright functionality with JavaScript examples, complete with CI/CD via GitHub Actions.
This ASP.NET Core web application showcases all the major features of Playwright, a powerful end-to-end testing framework. The application provides interactive examples that can be automated using Playwright for testing purposes.
- 🎯 Selectors & Locators: CSS selectors, XPath, text-based selectors, role-based selectors
- 🖱️ User Interactions: Clicks, double-clicks, hover, drag & drop, keyboard input
- 📝 Form Handling: Text inputs, checkboxes, radio buttons, dropdowns, file uploads
- 🚀 Navigation & Waits: Page navigation, dynamic content loading, waiting strategies
- 📸 Screenshots & Traces: Visual regression testing, trace recording for debugging
- 🎭 Dialog & Alerts: Browser alerts, confirms, prompts, and custom modals
- Backend: ASP.NET Core 8.0 with Razor Pages
- Frontend: Bootstrap 5, JavaScript
- Testing Framework: Playwright (examples in JavaScript)
- CI/CD: GitHub Actions
- .NET 8.0 SDK or later
- A modern web browser
- (Optional) Playwright for running automated tests
- Clone the repository:
git clone https://github.com/cardze/TryPlayWright.git
cd TryPlayWright- Navigate to the project directory:
cd PlaywrightDemo- Restore dependencies:
dotnet restore- Run the application:
dotnet run- Open your browser and navigate to:
http://localhost:5076
dotnet build --configuration Release
dotnet publish --configuration Release --output ./publishFor JavaScript/TypeScript:
npm init playwright@latestFor .NET:
dotnet add package Microsoft.Playwright
pwsh bin/Debug/net8.0/playwright.ps1 installconst { test, expect } = require('@playwright/test');
test('test selectors page', async ({ page }) => {
// Navigate to the app
await page.goto('http://localhost:5000/Selectors');
// Test CSS selector
await page.locator('#btn-primary').click();
// Test text selector
await page.getByText('Click Me').click();
// Take a screenshot
await page.screenshot({ path: 'selectors-test.png' });
});
test('test form handling', async ({ page }) => {
await page.goto('http://localhost:5000/Forms');
// Fill form
await page.locator('#name').fill('John Doe');
await page.locator('#email').fill('john@example.com');
// Select checkbox
await page.locator('#interest-coding').check();
// Select radio button
await page.locator('#exp-intermediate').check();
// Select dropdown
await page.locator('#country').selectOption('us');
// Submit form
await page.locator('button[type="submit"]').click();
// Verify result
await expect(page.locator('#form-result')).toBeVisible();
});TryPlayWright/
├── .github/
│ └── workflows/
│ └── dotnet-ci.yml # GitHub Actions CI/CD workflow
├── PlaywrightDemo/
│ ├── Pages/
│ │ ├── Index.cshtml # Home page with feature overview
│ │ ├── Selectors.cshtml # Selector demonstrations
│ │ ├── Interactions.cshtml # User interaction examples
│ │ ├── Forms.cshtml # Form handling examples
│ │ ├── Navigation.cshtml # Navigation and wait examples
│ │ ├── Screenshots.cshtml # Screenshot and trace examples
│ │ ├── Dialogs.cshtml # Dialog handling examples
│ │ └── Shared/
│ │ └── _Layout.cshtml # Main layout
│ ├── wwwroot/ # Static files (CSS, JS, images)
│ ├── Program.cs # Application entry point
│ └── PlaywrightDemo.csproj # Project file
└── README.md
The project includes a GitHub Actions workflow that automatically:
- Build: Compiles the .NET application
- Test: Runs all unit tests (when available)
- Publish: Creates deployment artifacts
- Deploy: Deploys to staging/production (configurable)
The workflow is triggered on:
- Push to
main,master, ordevelopbranches - Pull requests to these branches
- Manual workflow dispatch
Contributions are welcome! Please feel free to submit a Pull Request.
This project is open source and available for educational purposes.
Created to demonstrate Playwright testing capabilities with a .NET web application.
Happy Testing! 🎭