Net4x.BrowserLibrary 2.0.0.26283

dotnet add package Net4x.BrowserLibrary --version 2.0.0.26283
                    
NuGet\Install-Package Net4x.BrowserLibrary -Version 2.0.0.26283
                    
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="Net4x.BrowserLibrary" Version="2.0.0.26283" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Net4x.BrowserLibrary" Version="2.0.0.26283" />
                    
Directory.Packages.props
<PackageReference Include="Net4x.BrowserLibrary" />
                    
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 Net4x.BrowserLibrary --version 2.0.0.26283
                    
#r "nuget: Net4x.BrowserLibrary, 2.0.0.26283"
                    
#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 Net4x.BrowserLibrary@2.0.0.26283
                    
#: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=Net4x.BrowserLibrary&version=2.0.0.26283
                    
Install as a Cake Addin
#tool nuget:?package=Net4x.BrowserLibrary&version=2.0.0.26283
                    
Install as a Cake Tool

Net4x.BrowserLibrary

Selenium wrapper that turns a browser into a disposable session: one object owns the driver, quits it deterministically, and exposes DOM/JavaScript helpers on top of IWebDriver.

Supports Chrome (chromedriver) and Firefox (geckodriver) behind a single API.

Install

dotnet add package Net4x.BrowserLibrary

Target frameworks: net45, net461, net5.0-windows, net6.0-windows, net7.0-windows, net8.0-windows. Windows only (uses Windows Forms and the App Paths registry key to detect the installed browser).

The package ships build\Net4x.BrowserLibrary.props, which adds global using directives for OpenQA.Selenium, OpenQA.Selenium.Support.UI and OpenQA.Selenium.Support.Extensions.

Quick start

using BrowserLibrary;

using var utility = BrowserUtility.CreateInstance();          // Chrome
using var session = utility.OpenBrowser("https://example.com", []);

var title = session.Driver.GetInnerTextByXpath("//h1");

Firefox instead:

using var utility = BrowserUtility.CreateInstance(BrowserKind.Firefox);

One-shot page source, without holding a session open:

var html = utility.GetPageSource("https://example.com", []);

Hand the driver to code that outlives the session:

var driver = session.Detach();   // session no longer quits it; you now own it

API

BrowserUtility : IBrowserUtility

Member Purpose
CreateInstance() / CreateInstance(BrowserKind) Builds a utility; Chrome by default.
Kind The engine being driven.
OpenBrowser(url, optionsToAdd, maximized, useProfile) Opens a browser, returns a tracked IBrowserSession.
OpenBrowserAsync(...) Task-returning wrapper; the work is synchronous.
GetPageSource(...) / GetPageSourceAsync(...) Opens, reads PageSource, disposes.
GetDriver(...) Builds a driver not tracked by the utility — prefer OpenBrowser.
GetBrowserVersion() Version of this utility's browser, or null.
GetChromeVersion() / GetFirefoxVersion() Static probes for the installed browsers.
KillAllDrivers() Kills this utility's driver processes; a no-op while KillSuspended is true.
KillChromeDrivers() / KillGeckoDrivers() / KillAllBrowserDrivers() Static, machine-wide kills.
Dispose() Disposes every session still open.

IBrowserSession

Member Purpose
Driver The live IBrowserDriver; throws ObjectDisposedException after disposal.
PageSource Page source at the moment of the call, null once disposed.
Detach() Transfers driver ownership to the caller; disposal no longer quits it.
Dispose() Quits the driver. Idempotent, no finalizer.

Driver extensions (on IBrowserDriver)

Extension class Methods
BrowserExtension GetElementByXpath, GetWaitFunction
ClickExtension ClickElementByXpath, ClickElementsByXpath
InnerTextExtension GetInnerText, GetInnerTextById, GetInnerTextByXpath, GetInnerTextsByClassName, GetInnerTextsByXpath, GetInnerTextsByXpathScript
GetHtmlExtension GetHtmlByElementsAsync, GetXHtmlByElementsAsync, GetHtmlXDocumentAsync, GetXDocumentsByElementsAsync
EvaluateIfElseExtension EvaluateIfElseAsync (condition / body / else-body / wait-time overloads)
ExecuteScriptExtension ExecuteScriptWithRetry<T>, ExecuteScriptWithRetry
WebDriverExtensions ExecuteScript, ExecuteScript<T>, ExecuteAsyncScript, ExecuteAsyncScript<T> (also on plain IWebDriver, and for PinnedScript)
NavigateExtension Navigate(url)
PageExtension ReplaceHtml(html)
PopupExtension HandlePopup(element) — switches to the popup, returns an IDisposable that switches back

ExecuteScriptWithRetry retries 3 times with exponential back-off (2s, 4s, 8s) and swallows script, disposal and WebDriver errors, returning default. Replace the policy through ExecuteScriptExtension.RetryPolicy.

Browser options

optionsToAdd is forwarded verbatim as browser preferences and is not translated between engines — Chrome receives user-profile preferences, Firefox about:config preferences:

Chrome Firefox
download.default_directory browser.download.dir (plus browser.download.folderList=2)
download.prompt_for_download browser.download.useDownloadDir (inverted)
safebrowsing.enabled browser.safebrowsing.downloads.enabled
download.directory_upgrade no equivalent

Configuration keys

Read through ArgumentGetter (command line, appSettings, environment):

Key Effect
HideBrowser Runs headless / off-screen.
ignore-certificate-errors Passes the flag to the driver.
ExcludedArguments Chrome excludeSwitches, |-separated. Defaults to test-type|use-mock-keychain|enable-blink-features — enable-automation is deliberately not excluded, because Chrome 132+ exits at once when chromedriver launches it without that switch.

Driver resolution

A driver binary sitting next to the executing assembly (chromedriver.exe, geckodriver.exe) wins over Selenium Manager. Ship one to pin a version; otherwise Selenium Manager resolves against the installed browser.

Package Purpose
Net4x.Browser2012Library Same API, chromedriver 109 pinned for Windows Server 2012 / Chrome 109.
Net4x.HtmlPersist Scrapes HTML tables into DataTables and persists them.
Net4x.ZipCodesLibrary Italian ZIP-code/geography downloaders built on both.
Product Compatible and additional computed target framework versions.
.NET net5.0-windows7.0 is compatible.  net6.0-windows was computed.  net6.0-windows7.0 is compatible.  net7.0-windows was computed.  net7.0-windows7.0 is compatible.  net8.0-windows was computed.  net8.0-windows7.0 is compatible.  net9.0-windows was computed.  net10.0-windows was computed. 
.NET Framework net45 is compatible.  net451 was computed.  net452 was computed.  net46 was computed.  net461 is compatible.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on Net4x.BrowserLibrary:

Package Downloads
Net4x.HtmlPersist

Package Description

Net4x.ZipCodesLibrary

Package Description

Net4x.ChromeLibrary

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.0.26283 90 10/11/2026
2.0.0.26238 121 8/27/2026
1.3.0.2 171 1/6/2026
1.3.0.1 145 1/5/2026
1.3.0 291 3/31/2025
1.0.0.26246 100 9/3/2026