SeleniumGenius 1.0.0
There is a newer version of this package available.
See the version list below for details.
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" />
<PackageReference Include="SeleniumGenius" />
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
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#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
#tool nuget:?package=SeleniumGenius&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
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: 
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 classGeniusDriverTermination.Terminate()this class force close chrome drivers and chrome browsers.- π‘Tips: Have a HostedService with name
StopGeniusDriversHostedServicethat when application normally stopped try to kill all chrome drivers and chrome browsers
- π‘Tips: Have a HostedService with name
Options Settings βοΈ:
options.WithDimensions(): Set the dimensions and position of your Chrome window. Note that it does not work in headless mode.options.WithRelativeCachePath(): Customize the cache path for Chrome files to reduce login frequency and retain cookies.options.WithLogin(): A delegate executed before each run to ensure login. It's advisable to include logic to check for login status.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.options.WithHttpProxyServer(): Set a proxy server for your Chrome instance.options.WithIncognito(): Run the browser in incognito mode.options.WithDisableImages(): Disable all images for faster website loading.options.WithSupportDocker(): Configures settings on Chrome for running inside Docker.options.WithStartMaximized(): Launch the browser in maximized mode, not supported in headless mode.options.WithExtensions(): Add your own extensions to Chrome.options.WithDisablePopupBlocking(): Block all popups, useful for sites with excessive ads.options.WithHeadless(): Run Chrome without UI. Note that websites may detect you as a bot based on the UserAgent.options.WithDisposeDriverAfterTaskCompleted(): Dispose of the driver and browser resources after completing each operation.options.WithClearCacheAfterDispose(): Clear the cache after disposing of resources.options.WithMaxConcurrentDriver(): Determine the number of Chrome drivers to run simultaneously.options.WithLoginData(): Provide user data for logging in.
Errors:β
UnhandledGeniusException: This class helps you throw exceptions with a screenshot of the moment the error occurred.
| 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. 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.
-
net8.0
- Selenium.WebDriver (>= 4.17.0)
- Selenium.WebDriver.ChromeDriver (>= 121.0.6167.8500)
- Telegram.Bot (>= 18.0.0-alpha.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.