Easily add your auth proxies to your Firefox (Gecko) Driver with one line of code With Extension
You Can Simply Add this Library to your project with Nuget Package:
Install-Package SeleniumProxyAuthentication.Firefox -Version 1.0.0
! You need to download the "Nightly" or "Developer Edition" of firefox to use this library because in the original browser extensions should be verified before installing since version 43
- First you need to download the gecko driver from here (make sure that the version of your firefox browser should be match with the version of gecko driver that you download!)
https://github.com/mozilla/geckodriver/releases
-
Then put the geckodriver.exe in your project bin directory
-
Create a new Instance of FirefoxOptions and define the FirefoxProfile (if path of profile not set it will generate the profile randomly)
private static readonly FirefoxOptions FirefoxOptions = new() {Profile = new FirefoxProfile()};
- Pass the FirefoxOptions Instance to a new Instance of FirefoxDriver
IWebDriver driver = new FirefoxDriver(FirefoxOptions);
- Attach your proxy to the instance of firefox driver using extension method "AddProxyAuthenticationExtension"
driver.AddProxyAuthenticationExtension(new SeleniumProxyAuthentication.Proxy(
ProxyProtocols.HTTP,
"host:port:username:password"
));
driver.Navigate().GoToUrl(new Uri("https://github.com/"));
Thread.Sleep(5000);
driver.Quit();
- Remove Entire Cache That Created By Extensions using this method
driver.DeleteExtensionsCache();
- also see the sample project to see how it's work Link to sample project
- Support all kind of proxy types (i tested http/s, socks5)
- Host:Port:Username:Password
- Host:Port