LocatAI.NET
1.0.1
See the version list below for details.
dotnet add package LocatAI.NET --version 1.0.1
NuGet\Install-Package LocatAI.NET -Version 1.0.1
<PackageReference Include="LocatAI.NET" Version="1.0.1" />
<PackageVersion Include="LocatAI.NET" Version="1.0.1" />
<PackageReference Include="LocatAI.NET" />
paket add LocatAI.NET --version 1.0.1
#r "nuget: LocatAI.NET, 1.0.1"
#addin nuget:?package=LocatAI.NET&version=1.0.1
#tool nuget:?package=LocatAI.NET&version=1.0.1
LocatAI.NET
LocatAI.NET is an AI-powered Selenium WebDriver extension that uses OpenAI to intelligently locate web elements using natural language descriptions. Version 1.0.0 brings a stable, production-ready implementation with comprehensive caching, logging, and configuration options.
Features
- AI-powered element location using natural language descriptions
- Built-in caching system for successful locators with performance tracking
- Multiple API key configuration options
- Comprehensive logging and performance monitoring
- Full .NET Standard 2.0 and .NET 6.0+ support
- Configurable OpenAI model selection (default: gpt-4)
- Seamless integration with existing Selenium WebDriver code
Installation
Install via NuGet Package Manager:
Install-Package LocatAI.NET -Version 1.0.0
Or via .NET CLI:
dotnet add package LocatAI.NET --version 1.0.0
Getting Started
Install the Package Follow the installation instructions above to add LocatAI.NET to your project.
Create Configuration File Create a new file named
appsettings.json
in your project's root directory with the following content:{ "LocatAI": { "OpenAIApiKey": "your-api-key", "OpenAIModel": "gpt-4o-mini-2024-07-18", "DefaultWaitTimeoutSeconds": 10, "Cache": { "MaxSize": 100, "ExpirySeconds": 3600, "MinAttemptsForEviction": 5, "MinSuccessRateForEviction": 0.6, "MaxFailuresForEviction": 3, "CacheDirectory": "Cache" } } }
Configure API Key Replace
"your-api-key"
with your actual OpenAI API key using one of these methods (in order of precedence):- Set programmatically in code:
settings.SetApiKey("your-api-key");
- Use environment variable:
set OPENAI_API_KEY=your-api-key
- In appsettings.json (as shown above)
Start Using LocatAI
using LocatAI.NET; // Use AI to find elements var loginButton = await driver.FindElementByAIAsync("the login button"); var emailField = await driver.FindElementByAIAsync("email input field"); // Regular Selenium actions emailField.SendKeys("test@example.com"); loginButton.Click();
Configuration Options
Basic Settings
OpenAIApiKey
: Your OpenAI API keyOpenAIModel
: Model to use (defaults to "gpt-4")DefaultWaitTimeoutSeconds
: Default timeout for element searches (default: 10)
Cache Settings
"Cache": {
"MaxSize": 100, // Maximum number of cached locators
"ExpirySeconds": 3600, // Cache entry lifetime
"MinAttemptsForEviction": 5,
"MinSuccessRateForEviction": 0.6,
"MaxFailuresForEviction": 3,
"CacheDirectory": "Cache" // Directory for cache files
}
Advanced Usage
Custom API Key Provider
public class CustomApiKeyProvider : IApiKeyProvider
{
public string GetApiKey() => "your-custom-key";
public Task<string> GetApiKeyAsync() => Task.FromResult("your-custom-key");
}
var settings = new LocatAISettings(new CustomApiKeyProvider());
Usage Tracking
// Get usage statistics
var report = AIUsageTracker.Instance.GetReport();
Console.WriteLine($"API Success Rate: {report.ApiSuccessRate:P2}");
Console.WriteLine($"Cache Hit Rate: {report.CacheHitRate:P2}");
Console.WriteLine($"Estimated Cost: ${report.EstimatedCost:F2}");
Documentation
For detailed documentation and examples, visit our GitHub repository.
Version History
See CHANGELOG.md for version history and release notes.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. 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. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.Extensions.Caching.Memory (>= 7.0.0)
- Microsoft.Extensions.Configuration (>= 7.0.0)
- Microsoft.Extensions.Configuration.Binder (>= 7.0.0)
- Microsoft.Extensions.Configuration.EnvironmentVariables (>= 7.0.0)
- Microsoft.Extensions.Configuration.Json (>= 7.0.0)
- Microsoft.Extensions.DependencyInjection (>= 7.0.0)
- Microsoft.Extensions.Logging (>= 7.0.0)
- Microsoft.Extensions.Logging.Console (>= 7.0.0)
- OpenAI (>= 2.1.0)
- Selenium.Support (>= 4.21.0)
- Selenium.WebDriver (>= 4.21.0)
-
net6.0
- Microsoft.Extensions.Caching.Memory (>= 7.0.0)
- Microsoft.Extensions.Configuration (>= 7.0.0)
- Microsoft.Extensions.Configuration.Binder (>= 7.0.0)
- Microsoft.Extensions.Configuration.EnvironmentVariables (>= 7.0.0)
- Microsoft.Extensions.Configuration.Json (>= 7.0.0)
- Microsoft.Extensions.DependencyInjection (>= 7.0.0)
- Microsoft.Extensions.Logging (>= 7.0.0)
- Microsoft.Extensions.Logging.Console (>= 7.0.0)
- OpenAI (>= 2.1.0)
- Selenium.Support (>= 4.21.0)
- Selenium.WebDriver (>= 4.21.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.