STAF.UI.API 4.4.0

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

STAF - Simple Test Automation Framework

C# Selenium | .NET Selenium Framework | MCP Server for Selenium C# | Selenium WebDriver C# | Test Automation .NET | UI Testing C# | API Testing .NET | MSTest Selenium

NuGet .NET 10 License: MIT

STAF is a production-ready .NET test automation framework for Selenium-based UI testing, API testing, and Excel validation. It provides base classes, HTML reporting, parallel execution, and optional database and accessibility support. The framework is distributed as the STAF.UI.API NuGet package and targets .NET 10 with MSTest.

Note: This release targets .NET 10. Projects consuming STAF.UI.API must use .NET 10 or above.


Sample Project & MCP Agent

STAF.Selenium.Tests is the official template and reference implementation for STAF. It includes:

  • Working samples for every major STAF feature (UI, API, Excel, Database, Accessibility)
  • MCP Agent - Model Context Protocol server for Selenium + STAF. Use with Cursor, VS Code, or Visual Studio to:
    • Control browsers - Start Chrome/Edge/Firefox, navigate, click, type, take screenshots
    • Generate STAF code - Produce C# Selenium tests (Page Object Model, ReportResult, TestBaseClass) from natural language

Get started with the framework quickly by cloning the template:

git clone https://github.com/sooraj171/STAF.Selenium.Tests
cd STAF.Selenium.Tests
dotnet restore
dotnet build

See the STAF.Selenium.Tests repository for setup, MCP configuration, and sample tests.


Table of Contents


Overview

STAF streamlines automated testing for web applications and APIs using Selenium WebDriver and C#. It supports:

Area Capability
UI automation Page Object Model-style tests with Selenium (Chrome, Edge, local or remote)
API automation REST-style tests with the same reporting and lifecycle as UI tests
HTML reporting Per-test and assembly-level HTML reports with pass/fail summary and optional screenshots
Parallel execution Thread-safe reporting and MSTest parallelization (method-level, configurable workers)
Excel Compare workbooks/sheets and read/write cell data via ClosedXML
Database SQL Server helpers (connection, query, scalar, non-query) using configuration
Accessibility Axe-core (Deque.AxeCore.Selenium) integration for accessibility scans and HTML reports

Features

Feature Description
Base classes TestBaseClass (UI), TestBaseAPI (API), PageBaseClass (elements and waits)
Browser support Chrome, Edge; local or remote WebDriver. Overridable options and driver creation
HTML reporting In-test step reporting (Pass/Fail/Warn/Info) and assembly summary (ResultTemplateFinal.html)
Parallel execution Parallel-safe result accumulation; MSTest Parallelize (e.g. 4 workers, method scope)
Excel Compare two workbooks/sheets; get/set cell data; row/column counts
Database DbHelper: connection strings from config, execute query/scalar/non-query
Configuration appsettings.json and run settings (browser, driver path, URL, test parameters)
Email Optional email of test results (SMTP via config or TestContext)
Accessibility Axe-core page/element scans and styled HTML reports
Report generator Programmatic HTML reports via TestReportGenerator and TestResultData

Key Components

Test and Page Base Classes

Class Purpose
TestBaseClass Inherit for UI tests. Initializes WebDriver (from TestContext/run settings), sets up per-test HTML result file, and cleans up (including reporting to the assembly summary)
TestBaseAPI Inherit for API tests. Same startup/cleanup and reporting as UI tests, without a browser
PageBaseClass Wraps element location with wait: FindAppElement(By), FindAppElement(By, description), FindAppElement(parent, By, description)

Browser and Driver

Class Purpose
BrowserDriver Creates IWebDriver for Chrome or Edge, local or remote. Override SetChromeOptions() / SetEdgeOptions() or GetBrowserDriverObject() to customize

Reporting

Class Purpose
ReportResult Log steps for UI tests: ReportResultPass/Fail/Warn/Info(driver, TestContext, moduleName, description[, exception])
ReportResultAPI Same for API tests: ReportResultPass/Fail/Warn/Info(TestContext, moduleName, description[, exception])
HtmlResult Creates and appends to per-test HTML files. Used by report classes; supports screenshots on fail
ReportElement (extensions) Assert and report in one call: ReportElementExists, ReportElementIsDisplayed, ReportElementIsEnabled (with optional proceed-on-fail flag)

WebDriver Extensions

Method Purpose
CloseAllTabsExceptCurrent Close all browser tabs except the current one
getTotalTabsCount Return number of open tabs
waitForFindElement Find element with explicit timeout
waitForElementExist / waitForElementNotExist Wait for element presence/absence
WaitForElementDisapper Wait until element is no longer present (By)
WaitForDocumentReady Wait for document ready and (if present) jQuery idle

Excel, Database & Accessibility

Class Purpose
ExcelDriver CompareFiles, GetExcelWorkbook, GetExcelCellData, SetExcelCellData, GetExcelRowCount, GetExcelColumnCount
DbHelper Connection strings from AppConfig. OpenConnection, VerifyConnection, ExecuteQuery, ExecuteScalar, ExecuteNonQuery
AxeAccessibility Deque Axe-core: AnalyzePage(), AnalyzePageAndSaveHtml(), AnalyzeCssSelector(), AnalyzeElement(), AnalyzeWithConfigurator()

Getting Started

Prerequisites

  • .NET 10 SDK
  • Visual Studio 2022 (or later) or VS Code with C# extension
  • Chrome or Edge (for UI tests)
  • MSTest (included via package reference)

Install

  1. Add the NuGet package to your test project:

    dotnet add package STAF.UI.API
    

    Or use the sample project template for a complete setup with examples.

  2. Configure run settings: Test > Configure Run Settings > Select Solution Wide runsettings File > choose testrunsetting.runsettings.

  3. Build and run tests from Test Explorer or CLI: dotnet test.

Sample UI Test

[TestMethod]
public void TestLogin()
{
    var element = FindAppElement(By.Id("loginButton"), "Login button");
    ReportResult.ReportResultPass(driver, TestContext, "Login", "Login button is visible");
}

Sample API Test

[TestMethod]
public void TestAPIStatus()
{
    ReportResultAPI.ReportResultPass(TestContext, "API", "Status check passed");
}

Configuration

Run settings (testrunsetting.runsettings)

  • TestRunParameters: browser (e.g. chrome), driverPath, url, optional email/smtp settings
  • MSTest: Parallelize (e.g. Workers=4, Scope=MethodLevel)
  • ResultsDirectory: e.g. .\TestResults

appsettings.json

  • ConnectionStrings: e.g. DefaultConnection for DbHelper
  • Email: SmtpHost, SmtpPort, UseDefaultCred, Username, Password (optional)

Overriding browser options

protected override ChromeOptions SetChromeOptions()
{
    var options = new ChromeOptions();
    options.AddArguments("start-maximized");
    return options;
}

Reporting

In-test step reporting

ReportResult.ReportResultPass(driver, TestContext, "ModuleName", "Description");
ReportResult.ReportResultFail(driver, TestContext, "ModuleName", "Description", "exception text");

// API tests (no driver)
ReportResultAPI.ReportResultPass(TestContext, "ModuleName", "Description");

Element assertions with reporting

element.ReportElementExists(driver, TestContext, testName, "Element exists", ProdceedFlag: true);
element.ReportElementIsDisplayed(driver, TestContext, testName, "Element is displayed", ProdceedFlag: true);

Assembly summary

After all tests, AssemblyCleanup writes the combined result body to ResultTemplate.html and copies it to ResultTemplateFinal.html. Reporting is parallel-safe (file-based accumulator).


Usage Guide

Excel comparison

var excel = new ExcelDriver();
ExcelCompareStatus res = excel.CompareFiles("path/Excel1.xlsx", "path/Excel2.xlsx", sheetIndex1: 1, sheetIndex2: 1);
if (res.IsMatching) return true;

Accessibility (Axe)

var axe = new AxeAccessibility(driver);
axe.AnalyzePage();                                    // Full page scan
axe.AnalyzePageAndSaveHtml("report.html");            // Run and save HTML report
axe.AnalyzeCssSelector("#main");                      // Scoped scan
axe.AnalyzeWithConfigurator(b => b.Include(".modal")); // Custom configuration

Database (DbHelper)

Configure connection in appsettings.json under ConnectionStrings:DefaultConnection, then use:

DbHelper.VerifyConnection();
var value = DbHelper.ExecuteScalar<int>("SELECT COUNT(*) FROM Users");

License

This project is licensed under the MIT License.

Author: Sooraj Ramachandran
Copyright (c) 2026 Sooraj Ramachandran. All rights reserved.


Links
NuGet: STAF.UI.API
Sample project & MCP Agent: STAF.Selenium.Tests

This software is provided "as is", without warranty of any kind. See the license for full terms.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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
4.4.0 91 3/2/2026
4.3.3 129 12/30/2025
4.3.0 321 11/16/2025
4.2.0 249 10/31/2025
4.1.0 331 8/7/2025
4.0.3 273 6/26/2025
4.0.2 239 3/28/2025
4.0.0 266 3/20/2025
3.4.1 664 12/12/2023
3.3.0 989 7/16/2023
3.2.9 677 5/21/2023
3.2.8 1,248 4/20/2023
3.2.1 706 4/7/2023
3.2.0 735 4/1/2023
3.1.7 781 2/5/2023
3.1.0 800 1/25/2023
3.0.0 818 1/17/2023
2.0.2 856 1/16/2023
2.0.1 1,032 3/18/2022
Loading failed

This release targets .NET 10. Underlying projects consuming STAF.UI.API must use .NET 10 or above.
UI and API test framework for Selenium.
Supports Chrome, Edge & Remote Drivers.
Supports Parallel execution and is thread safe.
Click the repository link to setup and get started quickly with a sample project.
https://github.com/sooraj171/STAF.Selenium.Tests