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
<PackageReference Include="Net4x.BrowserLibrary" Version="2.0.0.26283" />
<PackageVersion Include="Net4x.BrowserLibrary" Version="2.0.0.26283" />
<PackageReference Include="Net4x.BrowserLibrary" />
paket add Net4x.BrowserLibrary --version 2.0.0.26283
#r "nuget: Net4x.BrowserLibrary, 2.0.0.26283"
#:package Net4x.BrowserLibrary@2.0.0.26283
#addin nuget:?package=Net4x.BrowserLibrary&version=2.0.0.26283
#tool nuget:?package=Net4x.BrowserLibrary&version=2.0.0.26283
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.
Related packages
| 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 | Versions 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. |
-
.NETFramework 4.5
- Net4x.BaseTypes (>= 1.3.1.26262)
- Net4x.FormLogging.Library (>= 1.4.0.26248)
- Net4x.HtmlCleaner (>= 1.4.0.26249)
- Net4x.UtilityLibrary (>= 1.5.1.26262)
- Polly (>= 7.2.4)
- Selenium.Support (>= 4.11.0)
- Selenium.WebDriver (>= 4.11.0)
-
.NETFramework 4.6.1
- Net4x.BaseTypes (>= 1.3.1.26262)
- Net4x.FormLogging.Library (>= 1.4.0.26248)
- Net4x.HtmlCleaner (>= 1.4.0.26249)
- Net4x.UtilityLibrary (>= 1.5.1.26262)
- Polly (>= 7.2.4)
- Selenium.Support (>= 4.13.1)
-
net5.0-windows7.0
- Net4x.BaseTypes (>= 1.3.1.26262)
- Net4x.FormLogging.Library (>= 1.4.0.26248)
- Net4x.HtmlCleaner (>= 1.4.0.26249)
- Net4x.UtilityLibrary (>= 1.5.1.26262)
- Polly (>= 8.4.1)
- Selenium.Support (>= 4.13.1)
-
net6.0-windows7.0
- Net4x.BaseTypes (>= 1.3.1.26262)
- Net4x.FormLogging.Library (>= 1.4.0.26248)
- Net4x.HtmlCleaner (>= 1.4.0.26249)
- Net4x.UtilityLibrary (>= 1.5.1.26262)
- Polly (>= 8.4.1)
- Selenium.Support (>= 4.13.1)
-
net7.0-windows7.0
- Net4x.BaseTypes (>= 1.3.1.26262)
- Net4x.FormLogging.Library (>= 1.4.0.26248)
- Net4x.HtmlCleaner (>= 1.4.0.26249)
- Net4x.UtilityLibrary (>= 1.5.1.26262)
- Polly (>= 8.4.1)
- Selenium.Support (>= 4.13.1)
-
net8.0-windows7.0
- Net4x.BaseTypes (>= 1.3.1.26262)
- Net4x.FormLogging.Library (>= 1.4.0.26248)
- Net4x.HtmlCleaner (>= 1.4.0.26249)
- Net4x.UtilityLibrary (>= 1.5.1.26262)
- Polly (>= 8.4.1)
- Selenium.Support (>= 4.13.1)
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 |