STAF.UI.API 4.1.0

dotnet add package STAF.UI.API --version 4.1.0
                    
NuGet\Install-Package STAF.UI.API -Version 4.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.UI.API" Version="4.1.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.1.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.1.0
                    
#r "nuget: STAF.UI.API, 4.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.UI.API@4.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.UI.API&version=4.1.0
                    
Install as a Cake Addin
#tool nuget:?package=STAF.UI.API&version=4.1.0
                    
Install as a Cake Tool

About:

  • STAF stands for Simple Test Automation Framework.
  • STAF.UI.API nuget for Page Object Model implementation of Selenium Framework.

Overview This repository contains an automation test framework built using Selenium WebDriver and C#. It is designed to streamline the creation and execution of automated tests for web applications and APIs, allowing for efficient reporting and error handling.

The framework consists of the following key components:

  • PageBaseClass: A base class to interact with web elements on the page with wait functionality.
  • TestBaseClass: A base test class for initializing and cleaning up WebDriver and running tests with Selenium.
  • TestBaseAPI: A class for running API tests with similar initialization and cleanup functionalities.
  • ReportResult: A utility class to handle reporting of test results including pass, fail, warn, and info statuses.

What it has

  • STAF is a test automation framework for c# projects using selenium.
  • STAF helps to automate API and UI Tests using REST and Selenium.
  • STAF has all base class written so you can inherit and use those.
  • STAF has a good HTML reporting as well for test result viewing.
  • Parallel Execution using native machine threads.
  • Excel Comparison and easy usage.
  • STAF framework is maintained by https://github.com/sooraj171

How to implement

From your Visual Studio IDE Navigate to file menu:

  • Extension → Manage Extension → Online Templates → Search "STAFTemplate".
  • Install the template successfully.
  • Create a new project from Visual Studio
  • Search for the template "STAFSample" and select it and create project
  • From the Build menu, Click Build Project
  • From Test Explorer, select the test and Click run.
  • A sample test will get executed.

How to Override the driver and driver options

To override BrowserOptions use SetChromeOptions / SetEdgeOptions Usage: protected override ChromeOptions SetChromeOptions() { return ChromeOptions;}

To override BrowserDriver Usage: public override IWebDriver GetBrowserDriverObject("Chrome", "", false) { return WebDriver;}

How to Use the Reporting options

Usage:
    ReportResult.ReportResultPass(Driver, context, testName, "Details.");
    ReportResultAPI.ReportResultPass(TestContext, "ModuleName/FunctionName", "Details");
Other Options:  
    ReportResultFail,ReportResultWarn,ReportResultInfo

How to Use Excel Options

ExcelDriver excel= new ExcelDriver();
        ExcelCompareStatus res = excel.CompareFiles("\Excel1.xlsx", "\Excel2.xlsx",SheetIndexFile1,SheetIndexFile2);
        if (res.IsMatching)
        {
           return true;
        }
        else
        {
            return false;
        }
        

Key Classes

1. PageBaseClass

  • Purpose: Handles interactions with web elements by locating them using various By expressions and waiting for them to be visible before performing actions.
  • Main Methods:
    • FindAppElement: Locates an element on the page with wait functionality.
    • FindAppElement(IWebElement parentElement): Locates an element within a specific parent element with wait functionality.

2. TestBaseClass

  • Purpose: A base test class that initializes the WebDriver and starts/stops tests, including performance monitoring.
  • Main Features:
    • Initializes the WebDriver for the browser type specified in the TestContext.
    • Records the total time for each test execution.
    • Handles test setup and cleanup with logging of start and stop times.

3. TestBaseAPI

  • Purpose: Similar to TestBaseClass but specifically used for API testing.
  • Main Features:
    • Handles API test initialization and cleanup.
    • Allows reporting of test execution status (Pass/Fail) for API-related tests.

4. ReportResult & ReportResultAPI

  • Purpose: These classes handle reporting the results of test executions.
  • Main Features:
    • Report test results with various statuses: Pass, Fail, Warn, Info.
    • Uses HtmlResult.TC_ResultCreation to generate HTML reports.
    • Can be used for both WebDriver-based tests (ReportResult) and API-based tests (ReportResultAPI).

Setup & Configuration

Prerequisites

  • .NET Framework or .NET Core: The framework is compatible with both.
  • Selenium WebDriver: Used for interacting with the browser.
  • TestContext: Required for passing test metadata (e.g., test name, test properties).

Environment Variables

  • browser: The type of browser to use (e.g., "Chrome", "Firefox").
  • driverPath: Path to the browser driver (e.g., ChromeDriver for Chrome).
  • Test Report Location: Ensure that a valid directory for reports is available.

API Test Setup

For API tests, the framework requires an endpoint to be set in the TestContext. This will be used during the test initialization.

Running Tests

Web Tests

  1. Initialize WebDriver: The framework will automatically pick up the browser type and driver path from the TestContext.
  2. Write Test: Create test methods using the TestBaseClass. Example:
[TestMethod] public  void  TestLogin()
{ // Test code here ReportResult.ReportResultPass(driver, TestContext, "Login", "Login button is visible");
}

API Tests

  • API Test Initialization: Set the endpoint in the TestContext properties.
  • Write API Test: Create test methods using TestBaseAPI. Example:
[TestMethod]
public void TestAPIStatus()
{
    // API test code here
    ReportResultAPI.ReportResultPass(TestContext, "API", "Status check passed");
}

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
4.1.0 212 8/7/2025
4.0.3 156 6/26/2025
4.0.2 151 3/28/2025
4.0.0 175 3/20/2025
3.4.1 558 12/12/2023
3.3.0 922 7/16/2023
3.2.9 606 5/21/2023
3.2.8 1,149 4/20/2023
3.2.1 621 4/7/2023
3.2.0 646 4/1/2023
3.1.7 706 2/5/2023
3.1.0 727 1/25/2023
3.0.0 740 1/17/2023
2.0.2 774 1/16/2023
2.0.1 940 3/18/2022
2.0.0 933 3/5/2022
1.0.1 889 2/16/2022
1.0.0 940 2/8/2022

UI and API test framework for Selenium.
Supports Chrome, Edge & Remote Drivers.
Supports Parallel execution and is thread safe.
Install STAFTemplate Test automation framework from Microsoft Market place. (From VS IDE -> Extension -> Manage Extension -> Online Templates -> Search "STAFTemplate"