STAF.Playwright
2.0.0
dotnet add package STAF.Playwright --version 2.0.0
NuGet\Install-Package STAF.Playwright -Version 2.0.0
<PackageReference Include="STAF.Playwright" Version="2.0.0" />
<PackageVersion Include="STAF.Playwright" Version="2.0.0" />
<PackageReference Include="STAF.Playwright" />
paket add STAF.Playwright --version 2.0.0
#r "nuget: STAF.Playwright, 2.0.0"
#:package STAF.Playwright@2.0.0
#addin nuget:?package=STAF.Playwright&version=2.0.0
#tool nuget:?package=STAF.Playwright&version=2.0.0
STAF.Playwright
A .NET test automation framework for web and API testing using Microsoft Playwright and MSTest. STAF (Simple Test Automation Framework) provides base classes, page object support, HTML reporting with screenshots, and configuration for multi-environment test runs.
Installation
Install the package from NuGet:
dotnet add package STAF.Playwright
Or from Package Manager Console in Visual Studio:
Install-Package STAF.Playwright
Requirements: .NET 8.0, MSTest, Microsoft Playwright (browsers installed via playwright install when using the framework).
Quick Start
- Add the package to your test project (see above).
- Inherit from
BaseTestin your test classes to get Playwright browser, context, and page setup/teardown. - Use
BasePagefor page objects and automatic step reporting, or call reporting APIs manually.
Web test example
using Microsoft.VisualStudio.TestTools.UnitTesting;
using STAF.Playwright.Framework;
[TestClass]
public class LoginTests : BaseTest
{
[TestMethod]
public async Task Login_ValidCredentials_Succeeds()
{
await Page.GotoAsync(ConfigManager.GetBaseUrl());
// Your test steps; BasePage methods report steps automatically
await ReportResult.ReportResultPass(Page, TestContext, "Login", "Login flow completed.");
}
}
API test example
[TestMethod]
public void Api_HealthCheck_ReturnsOk()
{
// Use TestBaseAPI and ApiClient with TestContext for automatic request reporting
ReportResultAPI.ReportResultPass(TestContext, "API/Health", "Health check passed.");
}
Features
- Playwright + MSTest ? Browser automation with MSTest lifecycle and parallel execution.
- Base classes ?
BaseTestfor setup/teardown;BasePagefor page objects with automatic step reporting. - HTML reports ? Generated in
TestResultswith screenshots on failure viaHtmlResult. - Reporting APIs ?
ReportResult(UI) andReportResultAPI(API) for pass/fail/info steps. - Configuration ?
.runsettingsand environment-specifictestdata.jsonwithConfigManager. - CI/CD ? Override settings with
STAF_-prefixed environment variables. - Extras ? Excel driver, SQL client, OpenAPI contract testing support.
Key Components
| Component | Purpose |
|---|---|
| BaseTest | Initializes Playwright browser/context/page, base URL navigation, cleanup, and execution timing. |
| BasePage | Page object base with GetLocator, FindAppElementAsync, ClickAsync, EnterTextAsync, PressAsync and automatic step reporting. |
| HtmlResult | Builds HTML result files and embeds screenshots for failed steps. |
| ReportResult | Reports UI test steps (pass/fail) and integrates with HtmlResult. |
| ReportResultAPI | Reports API test steps (pass/fail) for use in API test classes. |
| ConfigManager | Loads .runsettings and testdata.json, supports environment and STAF_ env overrides. |
Reporting
Automatic (default)
- UI: When using
BasePagemethods (FindAppElementAsync,ClickAsync,EnterTextAsync,PressAsync,GetLocator), steps are reported automatically. - API: When using
ApiClientwithTestContext(e.g. inTestBaseAPI), each request is reported by status (pass/fail).
Manual
ReportResult.ReportResultPass(Page, TestContext, "TestName", "Details.");
ReportResult.ReportResultFail(Page, TestContext, "TestName", "Details.");
ReportResultAPI.ReportResultPass(TestContext, "Module/Function", "Details");
ReportResultAPI.ReportResultFail(TestContext, "Module/Function", "Details");
Configuration
- Prerequisites: .NET 8, MSTest, Microsoft.Playwright.
- Run settings: Use a
testsetting.runsettingsfile (e.g.Environment,BaseUrl,ApiBaseUrl,Browser,Headless). See the repository?s CONFIGURATION.md for details. - Test data: Optional
testdata.jsonandtestdata.{Environment}.jsonmerged byConfigManager. - Environment variables: Override any runsettings parameter with
STAF_prefix (e.g.STAF_BaseUrl,STAF_Environment).
Repository and support
- Source and issues: GitHub ? STAF.Playwright.Tests
- Author: Sooraj Ramachandran
- Contributions and issues are welcome.
License and copyright
This project is licensed under the MIT License.
Copyright � 2026 Sooraj Ramachandran.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- ClosedXML (>= 0.105.0)
- Microsoft.Data.SqlClient (>= 5.2.2)
- Microsoft.OpenApi (>= 1.6.14)
- Microsoft.OpenApi.Readers (>= 1.6.14)
- Microsoft.Playwright (>= 1.56.0)
- MSTest.TestAdapter (>= 4.0.2)
- MSTest.TestFramework (>= 4.0.2)
- NJsonSchema (>= 10.9.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.