LocatAI.NET 1.0.1

There is a newer version of this package available.
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
                    
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="LocatAI.NET" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="LocatAI.NET" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="LocatAI.NET" />
                    
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 LocatAI.NET --version 1.0.1
                    
#r "nuget: LocatAI.NET, 1.0.1"
                    
#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.
#addin nuget:?package=LocatAI.NET&version=1.0.1
                    
Install LocatAI.NET as a Cake Addin
#tool nuget:?package=LocatAI.NET&version=1.0.1
                    
Install LocatAI.NET as a Cake Tool

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

  1. Install the Package Follow the installation instructions above to add LocatAI.NET to your project.

  2. 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"
        }
      }
    }
    
  3. Configure API Key Replace "your-api-key" with your actual OpenAI API key using one of these methods (in order of precedence):

    1. Set programmatically in code:
    settings.SetApiKey("your-api-key");
    
    1. Use environment variable:
    set OPENAI_API_KEY=your-api-key
    
    1. In appsettings.json (as shown above)
  4. 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 key
  • OpenAIModel: 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 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. 
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.9 241 4/13/2025 1.0.9 is deprecated because it is no longer maintained and has critical bugs.
1.0.8 118 4/13/2025
1.0.7 122 4/12/2025
1.0.6 118 4/12/2025
1.0.5 129 4/12/2025
1.0.4 117 4/12/2025
1.0.3 119 4/12/2025
1.0.2 115 4/12/2025
1.0.1 120 4/12/2025