STAF.Playwright 1.1.0

dotnet add package STAF.Playwright --version 1.1.0
                    
NuGet\Install-Package STAF.Playwright -Version 1.1.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="1.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="STAF.Playwright" Version="1.1.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 1.1.0
                    
#r "nuget: STAF.Playwright, 1.1.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@1.1.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=1.1.0
                    
Install as a Cake Addin
#tool nuget:?package=STAF.Playwright&version=1.1.0
                    
Install as a Cake Tool

STAF.Playwright

About:

  • STAF stands for Simple Test Automation Framework.
  • STAF.Playwright is a NuGet package for Page Object Model implementation using Microsoft Playwright and MSTest.

Overview
This repository contains an automation test framework built using Microsoft Playwright and C#. It is designed to streamline the creation and execution of automated UI tests for web applications, providing efficient reporting, error handling, and easy extensibility.

The framework consists of the following key components:

  • BaseTest: A base test class for initializing and cleaning up Playwright browser, context, and page objects.
  • HtmlResult: A utility class to handle HTML reporting of test results, including screenshots for failed steps.
  • ReportResult & ReportResultAPI: Utility classes for reporting test results (pass/fail/info) for UI and API scenarios.

What it has

  • STAF is a test automation framework for C# projects using Playwright.
  • Supports UI automation using Playwright with MSTest.
  • Provides base classes for easy test and page object inheritance.
  • Generates detailed HTML reports with screenshots for failures.
  • Parallel execution support.
  • Maintained by https://github.com/sooraj171

How to implement

From your Visual Studio IDE:

  • Install the NuGet package STAF.Playwright into your test project.
  • Reference your test project to the framework.
  • Inherit from BaseTest for your test classes.
  • Use the provided reporting utilities for result logging.
  • Build and run your tests from Test Explorer.

How to Use the Reporting options

Usage:

ReportResult.ReportResultPass(Page, TestContext, "TestName", "Details.");
ReportResultAPI.ReportResultPass(TestContext, "ModuleName/FunctionName", "Details");

Other Options:

  • ReportResultFail
  • ReportResultAPI.ReportResultFail

Key Classes

1. BaseTest

  • Purpose: Handles Playwright browser, context, and page initialization and cleanup. Provides access to Playwright objects and test context.
  • Main Features:
    • Initializes Playwright browser and page for each test.
    • Handles navigation to base URL.
    • Cleans up resources after test execution.
    • Records test execution time.

2. HtmlResult

  • Purpose: Generates HTML reports for test results, including screenshots for failed steps.
  • Main Features:
    • Creates and appends to HTML result files.
    • Embeds screenshots for failed steps.
    • Marks test status (Pass/Fail/Not Run).

3. ReportResult & ReportResultAPI

  • Purpose: Utility classes for reporting test results.
  • Main Features:
    • Report test results with various statuses: Pass, Fail.
    • Integrates with HtmlResult for HTML reporting.
    • Can be used for both Playwright-based UI tests and API-related tests.

Setup & Configuration

Prerequisites

  • .NET 8 (or compatible .NET version)
  • Microsoft.Playwright: Used for browser automation.
  • MSTest: Used for test structure and execution.

Environment Variables

  • BaseUrl: The base URL for your tests.
  • currTestName: The current test name (set automatically by the framework).
  • Test Report Location: Reports are generated in the TestResults directory by default.

Running Tests

Web Tests

  1. Inherit from BaseTest: Your test classes should inherit from BaseTest.
  2. Write Test: Create test methods using MSTest attributes. Example:
[TestMethod]
public async Task TestLogin()
{
    await Page.GotoAsync("https://example.com/login");
    // Test code here
    await ReportResult.ReportResultPass(Page, TestContext, "Login", "Login page loaded successfully");
}

API Tests

  • Use ReportResultAPI for reporting API test results. Example:
[TestMethod]
public void TestAPIStatus()
{
    // API test code here
    ReportResultAPI.ReportResultPass(TestContext, "API", "Status check passed");
}

For more details and sample usage, see the GitHub repository.
Contributions and issues are welcome!

License:

 This project is licensed under the MIT License.

� 2025 Sooraj Ramachandran. All Rights Reserved.

THIS 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 AUTHOR 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
1.1.0 201 11/23/2025
1.0.2 199 10/31/2025
1.0.1 132 9/12/2025