QualityAutomation.Selenium.Xunit 1.0.2

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

Quality Automation Selenium Helpers

Framework de automatización UI construido sobre Selenium WebDriver para .NET 6. Incluye drivers multi-browser, extensiones reutilizables, validaciones avanzadas, manejo de sesión, esperas explícitas y utilidades QA listas para usar con xUnit, NUnit y MSTest.


Caracteristicas

Compatible con
Chrome
Firefox
Microsoft Edge
xUnit
NUnit
MSTest
Incluye
DriverFactory multi-browser
Helpers reutilizables
Waits explícitos
Validaciones robustas
Regex validations
Extensiones sobre IWebDriver e IWebElement
Manejo de archivos descargados
Generación de datos aleatorios
Manejo de modales
Session Manager
Validaciones visuales

Tecnologías Utilizadas

Tecnología Propósito Enlace
.Net 6.0 Entorno de ejecución y SDK (.NET 6.0) Descargar .NET 6.0
Selenium Framework para automatización de navegador Sitio Oficial
NuGet Extensión de automatización de pruebas con Xunit Paquete NuGet

¿Qué incluye?

Esta librería no es solo un conjunto de extensiones — es un framework de automatización completo organizado en capas:

Módulo Descripción
Base Clase base BasePage con Driver, Wait y JavaScriptExecutor
Constants Timeouts y configuración centralizada
Drivers DriverFactory para Chrome, Firefox y Edge
Extensions Extensiones sobre IWebDriver, IWebElement y tablas
Helpers Navegación, waits, archivos, modales, links, randoms y validaciones
Models ValidationResult y SearchResult
Session Login, logout y manejo de sesión
Validations Validaciones de contenido, inputs, regex y errores visuales

Dependencias

Componente Versión
Target Framework net6.0
Selenium.WebDriver 4.25.0
Selenium.Support 4.25.0
DotNetSeleniumExtras.WaitHelpers 3.11.0
Selenium.Firefox.WebDriver 0.27.0
Selenium.WebDriver.MSEdgeDriver 129.0.2792.65

Requisitos del Sistema

Para consumir esta librería en tus proyectos de automatización, asegúrate de que el archivo .csproj de tu proyecto de pruebas cumpla con las siguientes especificaciones:

1. Framework y Configuración Básica

  • Framework: .NET 6.0 o superior (<TargetFramework>net6.0</TargetFramework>)
  • Habilitar modo test: <IsTestProject>true</IsTestProject>
  • Deshabilitar empaquetado: <IsPackable>false</IsPackable>

2. Estructura del .csproj Recomendada

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
    
    
    <IsPackable>false</IsPackable>
    <IsTestProject>true</IsTestProject>
  </PropertyGroup>

  <ItemGroup>
    
    <PackageReference Include="QualityAutomation.Selenium.Xunit" Version="1.0.X" />
    
    
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" />
    <PackageReference Include="xunit" Version="2.4.2" />
    <PackageReference Include="xunit.runner.visualstudio" Version="2.4.5" />
  </ItemGroup>

</Project>


Instalación

bash
dotnet add package QualityAutomation.Selenium.Helpers --version 1.0.X
powershell
# Package Manager Console <br> Install-Package QualityAutomation.Selenium.Helpers -Version 1.0.X

Los GlobalUsings del framework ya incluyen los namespaces de Selenium, WaitHelpers y los modelos internos. Solo necesitás agregar en tu proyecto:

csharp
using src.TestFrame.Extensions; <br>using src.TestFrame.Helpers; <br>using src.TestFrame.Validations;

Arquitectura del proyecto

src/TestFrame
├── GlobalUsings.cs
├── Base/
│   └── BasePage.cs              ← Clase base para Page Objects
├── Constants/
│   └── FrameworkDefaults.cs     ← Timeouts y configuración global
├── Drivers/
│   └── DriverFactory.cs         ← Creación de ChromeDriver
├── Extensions/
│   ├── TableExtensions.cs       ← Extensiones sobre tablas HTML
│   ├── WebDriverExtensions.cs   ← Extensiones sobre IWebDriver
│   └── WebElementExtensions.cs  ← Extensiones sobre IWebElement
├── Helpers/
│   ├── FileHelper.cs            ← Descarga y manejo de archivos
│   ├── LinkHelper.cs            ← Extracción y filtro de enlaces
│   ├── ModalHelper.cs           ← Confirmación de diálogos y modales
│   ├── NavigationHelper.cs      ← Navegación del browser
│   ├── RandomHelper.cs          ← Generación de datos de prueba
│   ├── ValidationHelper.cs      ← Validación de campos por reglas
│   └── WaitHelper.cs            ← Esperas explícitas
├── Models/
│   ├── SearchResult.cs
│   └── ValidationResult.cs
├── Session/
│   └── SessionManager.cs        ← Login, logout y cierre de sesión
└── Validations/
    ├── ContentValidation.cs     ← Validación de contenido en el DOM
    ├── InputValidation.cs       ← Validación de valores en inputs
    ├── RegexValidation.cs       ← Validación por expresiones regulares
    └── VisualValidation.cs      ← Detección de errores visibles en pantalla

Guía de uso rápida

1. Crear el driver, abrir y cerrar sesión

Ejemplo en un constructor de test (xUnit)

  • IWebDriver chrome = DriverFactory.CreateChrome();
  • IWebDriver firefox = DriverFactory.CreateFirefox();
  • IWebDriver edge = DriverFactory.CreateEdge();
using OpenQA.Selenium;

public class TestConLogin 
{
    private IWebDriver driver;
    private SessionManager log;

    public void EjecutarPruebaCompleta()
    {
        driver = DriverFactory.CreateChrome(false); 
        log = new SessionManager(driver);

        log.NavigateTo("example.com");
        log.Login(By.Id("user"), By.Id("pass"), "mi_usuario", "mi_clave", By.Id("submit"));
        
        log.LogoutByUrl("example.com");
        log.Logout(By.Id("btn-logout"));

        driver.Quit();
    }
}


2. Esperas explícitas (WaitHelper)

var el = WaitHelper.WaitVisible(driver, By.Id("resultado"));

var btn = WaitHelper.WaitClickable(driver, By.XPath("//button[@type='submit']"), 15);

bool appeared = WaitHelper.WaitExists(driver, By.ClassName("toast-success"));

string text = WaitHelper.WaitText(driver, By.Id("lblMensaje"));

3. Extensiones del driver (WebDriverExtensions)

bool exists = driver.Exists(By.Id("panel"));

bool hasContent = driver.HasRobustContent("//table", 5);

bool fieldHasData = driver.FieldHasData("txtName");

string value = driver.GetInputValue(By.Id("txtAmount"));

string text = driver.TryGetText(By.ClassName("title"));

4. Extensiones del elemento (WebElementExtensions)

input.ClearAndType("Datos");

search.ClearTypeAndEnter("Datos");

combo.ClickArrowDownAndEnter(2);

button.SafeClick();

string text = label.GetCleanText();

5. Extensiones de la tabla (TableExtensions)

string cellValue = driver.GetFirstRowCellText(By.XPath("//table/tbody/tr[1]/td[2]"));

bool matches = driver.FirstRowCellMatches(By.XPath("//table/tbody/tr[1]/td[1]"), "Juan Pérez");

bool hasRows = driver.HasAnyRow(By.XPath("//table/tbody/tr"));

bool isEmpty = driver.HasEmptyMessage(By.ClassName("empty-message"));

6. Archivos descargados (FileHelper)

bool downloaded = FileHelper.WaitForFileDownload(
    @"C:\Downloads",
    "*.xlsx");

bool exists = FileHelper.FileExistsByPattern(
    @"C:\Downloads",
    "*.pdf");

FileHelper.DeleteFilesByPattern(
    @"C:\Downloads",
    "*.xlsx");

var links = LinkHelper.GetAllLinks(driver);

bool exists = LinkHelper.ExistsLinkWithText(driver,
    "Inicio");

bool hasUrl = LinkHelper.HasLinkToUrl(driver,
    "google.com");

bool opensNewTab = LinkHelper.LinkOpensNewTab(
    driver,
    By.Id("external-link"));

8. Validación por Regex (RegexValidation)

RegexValidation.IsNumeric("123");

RegexValidation.IsDecimalNumber("12.50");

RegexValidation.IsEmail("qa@test.com");

RegexValidation.IsPhoneNumber("74291038");

RegexValidation.IsRomanNumber("XIV");

RegexValidation.IsCarPlate("1234 ABC");

RegexValidation.IsImageExtension("photo.jpg");

9. Datos aleatorios para pruebas (RandomHelper)

string name = RandomHelper.RandomString(10);

string email = RandomHelper.RandomEmail();

decimal amount = RandomHelper.RandomDecimal(10, 999);

string lorem = RandomHelper.RandomLoremIpsum(10, 20);

bool active = RandomHelper.RandomBool();

10. Manejo de validaciones (ContentValidation)

var result = ContentValidation.ValidateRobustContent(
    driver,
    "//table",
    3);

if (!result.IsValid)
{
    Console.WriteLine(result.Message);
}

11. Manejo de validaciones (VisualValidation)

var errors = new List<string>();

VisualValidation.CollectVisibleErrors(
    driver,
    errors,
    "Login",
    By.ClassName("error"),
    By.ClassName("alert-danger"));

Referencia completa de métodos

WebElementExtensions

Método Descripción
ClearAndType(value) Limpia y escribe.
ClearTypeAndEnter(value) Limpia, escribe y pulsa Enter.
ClearTypeAndTab(value) Limpia, escribe y pulsa Tab.
ClearTypeAndEscape(value) Limpia, escribe y pulsa Escape.
ClearTypeAndArrowDown(value, times) Limpia, escribe y navega N posiciones hacia abajo.
ClearTypeArrowDownAndEnter(value, arrowTimes) Limpia, escribe, baja N y confirma con Enter.
ClearTypeArrowUpAndEnter(value, arrowTimes) Limpia, escribe, sube N y confirma con Enter.
TypeAndEnter(value) Escribe y pulsa Enter sin limpiar.
TypeAndTab(value) Escribe y pulsa Tab sin limpiar.
SafeClick() Clic solo si Displayed && Enabled.
ClickAndPressKey(key) Clic y envía cualquier tecla.
ClickAndArrowDown(times) Clic y navega N posiciones hacia abajo.
ClickAndArrowUp(times) Clic y navega N posiciones hacia arriba.
ClickArrowDownAndEnter(times) Clic, baja N posiciones y confirma.
ClickArrowUpAndEnter(times) Clic, sube N posiciones y confirma.
ClickAndTab() Clic y Tab al siguiente campo.
ClickAndShiftTab() Clic y Shift+Tab al campo anterior.
PressEnter() Envía Enter sin clic previo.
PressTab() Envía Tab sin clic previo.
RepeatKey(key, times) Repite una tecla N veces.
GetCleanText() Retorna Text sin espacios. Nunca null.
GetValueOrEmpty() Retorna atributo value o string.Empty.

WebDriverExtensions

Método Descripción
Exists(by) Verdadero si existe al menos un elemento.
HasRobustContent(xpath, min) Verifica estructura mínima del contenedor sin mensajes de error.
FieldHasData(id) Verifica que un campo (input o select) tiene valor seleccionado.
GetInputValue(by) Retorna el atributo value recortado.
TryGetText(by) Retorna el texto del primer elemento o string.Empty.

TableExtensions

Método Descripción
GetFirstRowCellText(locator, timeout) Obtiene texto de la primera celda con espera.
FirstRowCellMatches(locator, expected) Compara el texto de la primera celda.
HasAnyRow(rowsLocator) Verdadero si la tabla tiene al menos una fila.
HasEmptyMessage(messageLocator) Verdadero si el mensaje de vacío está visible.
TryGetFirstRowCellText(locator) Intenta obtener el texto sin espera; retorna "" si falla.

WaitHelper

Método Descripción
CreateDefault(driver) WebDriverWait con timeout por defecto (10s).
Create(driver, seconds) WebDriverWait con timeout personalizado.
WaitVisible(driver, by, timeout) Espera hasta que el elemento sea visible.
WaitClickable(driver, by, timeout) Espera hasta que el elemento sea clickeable.
WaitExists(driver, by, timeout) Espera hasta que el elemento exista en el DOM.
WaitText(driver, by, timeout) Espera hasta que el elemento tenga texto no vacío.

RandomHelper

Método Descripción
RandomString(length) Cadena alfanumérica aleatoria.
RandomNumberString(length) Cadena numérica aleatoria.
RandomInt(min, max) Entero aleatorio en rango.
RandomDecimal(min, max, decimals) Decimal aleatorio con precisión configurable.
RandomDate(daysBack, format) Fecha aleatoria dentro de N días atrás.
RandomTime(fromHour, toHour, format) Hora aleatoria en rango.
RandomLoremIpsum(minWords, maxWords) Texto Lorem Ipsum de longitud variable.
RandomEmail(domain) Email aleatorio con dominio personalizable.
RandomFromList<T>(items) Elemento aleatorio de una lista.
RandomBool() Booleano aleatorio.

FrameworkDefaults

Constante Valor Uso
DefaultTimeoutSeconds 10 Timeout estándar
LongTimeoutSeconds 20 Operaciones lentas
ShortTimeoutSeconds 5 Verificaciones rápidas
DefaultDonwloadFolder "Downloads" Carpeta de descargas

Notas importantes

SafeClick vs Click nativo
SafeClick() verifica Displayed && Enabled antes de actuar. Previene ElementNotInteractableException en botones que se habilitan/deshabilitan dinámicamente.

ClearAndType vs SendKeys directo
En aplicaciones con valores por defecto, SendKeys sin Clear() previo concatena texto. ClearAndType garantiza que el campo empiece vacío.

Autocomplete y dropdowns dinámicos
ClearTypeArrowDownAndEnter replica el flujo real del usuario: filtra escribiendo, navega con flechas y confirma. Es más estable que localizar el ítem del dropdown directamente en el DOM.

FileHelper en archicos locales
FileHelper se encarga de verificar la existencia de un archivo al igual que eliminar y verificar la descarga WaitForFileDownload() que igual es compatible con Chrome, Firefox y Edge Chromium.

ValidationResult como tipo de retorno
Todos los métodos de validación retornan ValidationResult. Usá result.IsValid para bifurcar y result.Message para logging o assertions descriptivos en el reporte del test.

DriverFactory y CI/CD
El modo headless: true incluye --window-size=1920,1080 automáticamente y desactiva GPU para entornos sin pantalla como pipelines de Azure DevOps.


Autor : Personal QA :v


Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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.0.2 118 5/25/2026
1.0.1 107 5/13/2026
1.0.0 125 5/8/2026