SeleniumProxyAuth 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 SeleniumProxyAuth --version 1.0.0
NuGet\Install-Package SeleniumProxyAuth -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="SeleniumProxyAuth" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SeleniumProxyAuth --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: SeleniumProxyAuth, 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.
// Install SeleniumProxyAuth as a Cake Addin #addin nuget:?package=SeleniumProxyAuth&version=1.0.0 // Install SeleniumProxyAuth as a Cake Tool #tool nuget:?package=SeleniumProxyAuth&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Selenium proxy authentication library for .NET
The challenge
Selenium does not support basic proxy authentication out-of-the-box. It is possible to create an extension that handles proxy authentication and add the extension to the browser, but if you wish to run the driver headless, extensions are not loaded. That's why I created this library.
Workaround
The workaround is to create a local proxy server (this simple library uses Titanium-Web-Proxy) and handle the proxy authentication from there.
Instructions
- Create the local proxy server
var proxyServer = new SeleniumProxyAuth();
- Add a new endpoint
var localPort = proxyServer.AddEndpoint(new ProxyAuth("123.123.123.123", 80, "prox-username1", "proxy-password1"));
- Use the endpoint's port when initializing the driver
options.AddArgument($"--proxy-server=127.0.0.1:{localPort}");
Example
public void Test()
{
// Create a local proxy server
var proxyServer = new SeleniumProxyAuth();
// Don't await, have multiple drivers at once using the local proxy server
TestSeleniumProxyServer(proxyServer, new ProxyAuth("123.123.123.123", 80, "prox-username1", "proxy-password1"));
TestSeleniumProxyServer(proxyServer, new ProxyAuth("11.22.33.44", 80, "prox-username2", "proxy-password2"));
TestSeleniumProxyServer(proxyServer, new ProxyAuth("111.222.222.111", 80, "prox-username3", "proxy-password3"));
while (true) { }
}
private async Task TestSeleniumProxyServer(SeleniumProxyAuth proxyServer, ProxyAuth auth)
{
// Add a new local proxy server endpoint
var localPort = proxyServer.AddEndpoint(auth);
ChromeOptions options = new ChromeOptions();
//options1.AddArguments("headless");
// Configure the driver's proxy server to the local endpoint port
options.AddArgument($"--proxy-server=127.0.0.1:{localPort}");
// Optional
var service = ChromeDriverService.CreateDefaultService();
service.HideCommandPromptWindow = true;
// Create the driver
var driver = new ChromeDriver(service, options);
// Test if the driver is working correctly
driver.Navigate().GoToUrl("https://www.myip.com/");
await Task.Delay(5000);
driver.Navigate().GoToUrl("https://amibehindaproxy.com/");
await Task.Delay(5000);
// Dispose the driver
driver.Dispose();
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. 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. |
.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.
-
.NETStandard 2.0
- Titanium.Web.Proxy (>= 3.1.1344)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.