Playwright Integration
Prova provides first-class support for UI testing with Microsoft.Playwright. The Prova.Playwright package eliminates boilerplate code by managing the browser lifecycle automatically.
Getting Started
Install the Package
bashdotnet add package Prova.PlaywrightInstall Browsers Ensure Playwright browsers are installed:
bashpwsh bin/Debug/net10.0/playwright.ps1 installNote: This script is copied to your output directory during build.
Inherit from
PageTestCreate a test class that inherits fromProva.Playwright.PageTest. This gives you access to a freshPage,Context, andBrowserfor every test.csharpusing Prova; using Prova.Playwright; using System.Threading.Tasks; public class MyUiTests : PageTest { [Fact] public async Task VerifyHomePage() { await Page.GotoAsync("https://example.com"); await Expect(Page).ToHaveTitleAsync("Example Domain"); } }
Lifecycle Management
Prova manages the Playwright resources efficiently:
- Playwright Instance: Created once per assembly/process (lazy).
- Browser: Launched once (default: Headless Chromium). Configurable via
TestContextor global config (coming soon). - BrowserContext: A new isolated context is created before every test.
- Page: A new page is created before every test.
After each test, the Page and Context are closed, ensuring clean state for the next test.
Configuration
(Coming Soon)
- Browser selection (Chromium, Firefox, WebKit)
- Headless mode toggle
- Viewport size
- Record video/trace