G4.Abstraction 2024.11.14.74

There is a newer version of this package available.
See the version list below for details.
dotnet add package G4.Abstraction --version 2024.11.14.74                
NuGet\Install-Package G4.Abstraction -Version 2024.11.14.74                
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="G4.Abstraction" Version="2024.11.14.74" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add G4.Abstraction --version 2024.11.14.74                
#r "nuget: G4.Abstraction, 2024.11.14.74"                
#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.
// Install G4.Abstraction as a Cake Addin
#addin nuget:?package=G4.Abstraction&version=2024.11.14.74

// Install G4.Abstraction as a Cake Tool
#tool nuget:?package=G4.Abstraction&version=2024.11.14.74                

G4.Abstraction

G4.Abstraction provides an abstraction layer for creating WebDriver instances with configurable parameters. This library allows developers to initialize WebDriver instances with options for command timeouts, driver types, binary paths (local file path or grid endpoint), service configurations, and driver capabilities. It simplifies the setup process for automated browser interactions in remote or local environments.

Installation

To install G4.Abstraction, add the NuGet package:

dotnet add package G4.Abstraction

Features

  • Driver Creation Abstraction: Simplifies the process of creating WebDriver instances with custom configuration.
  • Plugin-Based Driver Management: Supports adding custom driver plugins to extend functionality.
  • Service Configuration: Supports service parameters for additional customization.
  • Serialization Options: Uses camel-case naming for JSON serialization and deserialization.
  • Remote and Local Driver Support: Detects if drivers are local (using a file path) or remote (using a grid endpoint URL).

Usage

1. Local Driver Example

In this example, the driverBinaries path points to a local file path where the driver binary (e.g., MicrosoftEdgeDriver.exe) is located. This configuration is suitable for running WebDriver instances on the local machine.

using G4.Abstraction;

var driverParams = new Dictionary<string, object>
{
    { "driver", "MicrosoftEdgeDriver" },
    { "commandTimeout", 60000 },
    { "driverBinaries", @"C:\path\to\MicrosoftEdgeDriver.exe" },  // Local file path
    { "capabilities", new CapabilitiesModel
        {
            AlwaysMatch = new Dictionary<string, object>
            {
                { "browserName", "MicrosoftEdge" },
                { "platformName", "Windows 10" }
            },
            FirstMatch = new List<Dictionary<string, object>>
            {
                new Dictionary<string, object> { { "browserVersion", "latest" } }
            }
        }
    }
};

var driverFactory = new DriverFactory(driverParams);
var webDriver = driverFactory.NewDriver();

2. Remote Driver Example

For remote setups, the driverBinaries parameter points to a grid endpoint URL (e.g., Selenium Grid or BrowserStack), which allows running tests on remote browsers. This configuration is useful for distributed testing across different platforms.

using G4.Abstraction;

var driverParams = new Dictionary<string, object>
{
    { "driver", "MicrosoftEdgeDriver" },
    { "commandTimeout", 60000 },
    { "driverBinaries", "http://localhost:4444/wd/hub" },  // Grid endpoint URL
    { "capabilities", new CapabilitiesModel
        {
            AlwaysMatch = new Dictionary<string, object>
            {
                { "browserName", "MicrosoftEdge" },
                { "platformName", "Windows 10" }
            },
            FirstMatch = new List<Dictionary<string, object>>
            {
                new Dictionary<string, object> { { "browserVersion", "latest" } },
                new Dictionary<string, object> { { "headless", true } }
            }
        }
    }
};

var driverFactory = new DriverFactory(driverParams);
var webDriver = driverFactory.NewDriver();

Work in Progress

  • Service Parameter Integration: Future versions will include support for service parameters during the initialization of new driver instances.

Error Handling

The DriverFactory includes detailed error handling. If the specified driver or initialization method is not found, a NotImplementedException or MissingMethodException is thrown with a detailed error message.

License

This library is released under the Apache License 2.0.

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

NuGet packages (1)

Showing the top 1 NuGet packages that depend on G4.Abstraction:

Package Downloads
G4.Plugins

The G4™ Framework Plugins Core package provides essential infrastructure for building extensible plugins within the G4™ automation engine. Developers can create diverse plugins that seamlessly integrate with G4's core functionality.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2024.11.14.75 335 11/14/2024
2024.11.14.74 93 11/14/2024
2024.11.14.73 94 11/14/2024
2024.11.14.72 97 11/14/2024
2024.11.13.70 98 11/13/2024
2024.11.12.63 110 11/12/2024