Installation
Introduction
CSTesting for C# is a .NET client for browser automation with the same API style as the Node.js and Java clients. Use Playwright under the hood. Project location: C:\CSTesting-DotNet.
Requirements
- .NET 8.0 SDK
- Playwright browsers — install once:
pwsh bin/Debug/net8.0/playwright.ps1 installorplaywright install chromiumfrom your test project output.
Install
# Add project references (from your test project)
dotnet add reference path/to/CSTesting/src/CSTesting/CSTesting.csproj
dotnet add reference path/to/CSTesting/src/CSTesting.NUnit/CSTesting.NUnit.csproj
# Or NuGet when published:
# dotnet add package CSTesting
# dotnet add package CSTesting.NUnit
From C:\CSTesting-DotNet: dotnet add reference C:\CSTesting-DotNet\src\CSTesting\CSTesting.csproj and the CSTesting.NUnit project if you use the NUnit fixture base.
Quick start
using CSTesting;
using static CSTesting.CSTesting;
var options = new CSTestingOptions { Headless = true };
await using var browser = await CreateBrowserAsync(options);
await browser.GotoAsync("https://example.com");
await browser.ClickAsync("a");
await browser.TypeAsync("input", "hello");
var text = await browser.Locator("h1").GetTextContentAsync();
await browser.CloseAsync();
NUnit base class
Record in the EasyTesting (CSTesting) Node app and export as C#. Tests typically extend CSTestingNUnitBrowserFixtureBase (or CSTestingTestBase) and assign Browser in [SetUp] — see SampleRecordedTest.cs in C:\CSTesting-DotNet:
npx cstesting record https://example.com --output RecordedTest.cs --format cs
Add the generated file to your .NET test project and run dotnet test.
System requirements
- .NET 8.0
- Playwright browsers installed (Chromium, etc.).
- OS: Windows, macOS, or Linux.