Testing Integration
Playwright Integration
End-to-end browser testing with Playwright for .NET.
Overview
Section titled “Overview”C# Dev Tools supports Playwright test projects for browser automation testing.
Test Discovery
Section titled “Test Discovery”Playwright tests are discovered automatically:
- Test Explorer recognizes Playwright test projects
- Tests appear alongside unit tests
- Organized by test class and method
Running Playwright Tests
Section titled “Running Playwright Tests”Run browser tests like any other test:
- Click “Run Test” in Test Explorer
- Or right-click test project: “Run Tests”
- Browser launches and executes tests
- Results appear in Test Explorer
Debugging Playwright Tests
Section titled “Debugging Playwright Tests”Debug browser interactions:
- Set breakpoints in test code
- Click “Debug Test” in Test Explorer
- Debugger stops at breakpoints
- Inspect browser state and variables
Creating Playwright Tests
Section titled “Creating Playwright Tests”Create test files with templates:
- Use Quick Add:
MyPlaywrightTest.cs - Or right-click: Add > New File
- Template includes Playwright setup
Common Scenarios
Section titled “Common Scenarios”Page Navigation
Section titled “Page Navigation”await page.GotoAsync("https://example.com");Element Interaction
Section titled “Element Interaction”await page.ClickAsync("#submit-button");await page.FillAsync("#username", "testuser");Assertions
Section titled “Assertions”await Expect(page.Locator("h1")).ToHaveTextAsync("Welcome");Best Practices
Section titled “Best Practices”- Use Page Object Model pattern
- Keep tests independent
- Use proper wait strategies
- Clean up browser state between tests
- Configure timeouts appropriately
Configuration
Section titled “Configuration”Configure Playwright in test project:
- Browser types (Chromium, Firefox, WebKit)
- Headless vs headed mode
- Screenshots on failure
- Video recording
- Timeout settings
Integration Benefits
Section titled “Integration Benefits”- Unified test management
- Combined unit and E2E test results
- Consistent debugging experience
- Single test runner for all tests