SeleniumGenius 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package SeleniumGenius --version 1.0.0
                    
NuGet\Install-Package SeleniumGenius -Version 1.0.0
                    
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="SeleniumGenius" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SeleniumGenius" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="SeleniumGenius" />
                    
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 SeleniumGenius --version 1.0.0
                    
#r "nuget: SeleniumGenius, 1.0.0"
                    
#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 SeleniumGenius@1.0.0
                    
#: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=SeleniumGenius&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=SeleniumGenius&version=1.0.0
                    
Install as a Cake Tool

SeleniumGenius πŸš€

SeleniumGenius is an expert tool for working with Selenium, providing access to the core Selenium settings along with the following features:

What Problems Can I Solve? πŸ› οΈ

  • πŸ’Ύ Memory leakage issue after force-closing the application on its first run.
  • πŸ“₯ Automatic download of compatible driver versions for the browser.
  • πŸ” Ensuring that your browser is always logged in.
  • 🏁 Resolving concurrency issues with multiple threads sending commands to Chrome.
  • ✨ Support from CancellationToken
  • πŸ”€ Running multiple instances of the driver to utilize more processing power simultaneously without interference between different instances.
  • 🧹 Optional disposal of the driver after completing tasks and clearing the browser cache after disposal.
  • πŸ‹ Settings for Docker support.
  • 🌐 Having a dedicated HttpClient for sending requests to the site using browser cookies.

Using SeleniumGenius πŸ“

All of these features are abstracted behind a single method called CreateAsync. After adding the service, simply inject the SeleniumGeniusFactory class and use its CreateAsync method:

_ = await seleniumGeniusFactory.CreateAsync(cancellationToken);

Installation and Setup: Nuget

Via PMC (Package manager console):
PM> Install-Package SeleniumGenius
Via dotnet CLI
dotnet add package SeleniumGenius

Then add the following settings to your services:

builder.AddSeleniumGenius(options =>
{
    options.WithLoginData(new List<LoginData>()
    {
        new()
        {
            Username = "admin",
            Password = "Admin@123",
            Email = "admin@admin.com"
        }
    });

    options.WithLogin(loginRequest =>
    {
        return new LoginResult(true, "successfully logged in");
    });
}, service =>
{
    service.EnableVerboseLogging = false;
    service.SuppressInitialDiagnosticInformation = true;
    service.HideCommandPromptWindow = true;
});
  • Here, options represents ChromeOptions, and service represents ChromeDriverService. Various sample settings are provided below, and we'll delve into each setting in detail.
  • πŸ“’ Also you can use builder.AddSeleniumGeniusWithPreTermination() this method just work on windows linux and mac not supported, this method within itself use static class GeniusDriverTermination.Terminate() this class force close chrome drivers and chrome browsers.
    • πŸ’‘Tips: Have a HostedService with name StopGeniusDriversHostedService that when application normally stopped try to kill all chrome drivers and chrome browsers

Options Settings βš™οΈ:

  1. options.WithDimensions(): Set the dimensions and position of your Chrome window. Note that it does not work in headless mode.
  2. options.WithRelativeCachePath(): Customize the cache path for Chrome files to reduce login frequency and retain cookies.
  3. options.WithLogin(): A delegate executed before each run to ensure login. It's advisable to include logic to check for login status.
  4. options.AddHttpClientIntegratedWithSeleniumCookies(): Provides an HttpClient that sends all site cookies in a header. It also configures a proxy for HttpClient when running the application on Windows during development.
  5. options.WithHttpProxyServer(): Set a proxy server for your Chrome instance.
  6. options.WithIncognito(): Run the browser in incognito mode.
  7. options.WithDisableImages(): Disable all images for faster website loading.
  8. options.WithSupportDocker(): Configures settings on Chrome for running inside Docker.
  9. options.WithStartMaximized(): Launch the browser in maximized mode, not supported in headless mode.
  10. options.WithExtensions(): Add your own extensions to Chrome.
  11. options.WithDisablePopupBlocking(): Block all popups, useful for sites with excessive ads.
  12. options.WithHeadless(): Run Chrome without UI. Note that websites may detect you as a bot based on the UserAgent.
  13. options.WithDisposeDriverAfterTaskCompleted(): Dispose of the driver and browser resources after completing each operation.
  14. options.WithClearCacheAfterDispose(): Clear the cache after disposing of resources.
  15. options.WithMaxConcurrentDriver(): Determine the number of Chrome drivers to run simultaneously.
  16. options.WithLoginData(): Provide user data for logging in.

Errors:❗

  1. UnhandledGeniusException: This class helps you throw exceptions with a screenshot of the moment the error occurred.
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.  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.10 212 5/14/2024
1.0.9 206 4/27/2024
1.0.8 188 4/26/2024
1.0.7 185 4/26/2024
1.0.6 127 4/20/2024
1.0.5 133 4/20/2024
1.0.4 134 4/20/2024
1.0.3 126 4/18/2024
1.0.2 123 4/18/2024
1.0.1 133 4/10/2024
1.0.0 132 4/10/2024