G4.Abstraction
2024.11.14.75
dotnet add package G4.Abstraction --version 2024.11.14.75
NuGet\Install-Package G4.Abstraction -Version 2024.11.14.75
<PackageReference Include="G4.Abstraction" Version="2024.11.14.75" />
paket add G4.Abstraction --version 2024.11.14.75
#r "nuget: G4.Abstraction, 2024.11.14.75"
// Install G4.Abstraction as a Cake Addin #addin nuget:?package=G4.Abstraction&version=2024.11.14.75 // Install G4.Abstraction as a Cake Tool #tool nuget:?package=G4.Abstraction&version=2024.11.14.75
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 | Versions 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. |
-
net8.0
- G4.Cache (>= 2024.11.14.75)
- G4.Extensions (>= 2024.11.14.75)
- G4.WebDriver.Remote.Android (>= 2024.11.14.75)
- G4.WebDriver.Remote.Chrome (>= 2024.11.14.75)
- G4.WebDriver.Remote.Chromium (>= 2024.11.14.75)
- G4.WebDriver.Remote.Edge (>= 2024.11.14.75)
- G4.WebDriver.Remote.Firefox (>= 2024.11.14.75)
- G4.WebDriver.Remote.Opera (>= 2024.11.14.75)
- G4.WebDriver.Remote.Simulator (>= 2024.11.14.75)
- G4.WebDriver.Remote.Uia (>= 2024.11.14.75)
- Newtonsoft.Json (>= 13.0.3)
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 | 180 | 11/14/2024 |
2024.11.14.74 | 87 | 11/14/2024 |
2024.11.14.73 | 88 | 11/14/2024 |
2024.11.14.72 | 92 | 11/14/2024 |
2024.11.13.70 | 93 | 11/13/2024 |
2024.11.12.63 | 101 | 11/12/2024 |