STAF.Playwright 2.0.0

dotnet add package STAF.Playwright --version 2.0.0
                    
NuGet\Install-Package STAF.Playwright -Version 2.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="STAF.Playwright" Version="2.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="STAF.Playwright" Version="2.0.0" />
                    
Directory.Packages.props
<PackageReference Include="STAF.Playwright" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add STAF.Playwright --version 2.0.0
                    
#r "nuget: STAF.Playwright, 2.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package STAF.Playwright@2.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=STAF.Playwright&version=2.0.0
                    
Install as a Cake Addin
#tool nuget:?package=STAF.Playwright&version=2.0.0
                    
Install as a Cake Tool

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.

NuGet
.NET 8
License: MIT


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

  1. Add the package to your test project (see above).
  2. Inherit from BaseTest in your test classes to get Playwright browser, context, and page setup/teardown.
  3. Use BasePage for 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 ? BaseTest for setup/teardown; BasePage for page objects with automatic step reporting.
  • HTML reports ? Generated in TestResults with screenshots on failure via HtmlResult.
  • Reporting APIs ? ReportResult (UI) and ReportResultAPI (API) for pass/fail/info steps.
  • Configuration ? .runsettings and environment-specific testdata.json with ConfigManager.
  • 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 BasePage methods (FindAppElementAsync, ClickAsync, EnterTextAsync, PressAsync, GetLocator), steps are reported automatically.
  • API: When using ApiClient with TestContext (e.g. in TestBaseAPI), 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.runsettings file (e.g. Environment, BaseUrl, ApiBaseUrl, Browser, Headless). See the repository?s CONFIGURATION.md for details.
  • Test data: Optional testdata.json and testdata.{Environment}.json merged by ConfigManager.
  • Environment variables: Override any runsettings parameter with STAF_ prefix (e.g. STAF_BaseUrl, STAF_Environment).

Repository and support


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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.0 32 2/12/2026
1.2.0 87 2/7/2026
1.1.0 208 11/23/2025
1.0.2 203 10/31/2025
1.0.1 139 9/12/2025