Heading
Hi everyone! I have been struggling with figuring out how to "allow all remote connections" with a proxy in ChromeDriver in C#. ======== START =============
ChromeDriverService service = ChromeDriverService.CreateDefaultService();
service.WhitelistedIPAddresses = ""; // NOTE: The idea is to allow all remote
connections. How to allow all IPs?
service.Port = 9515;
ChromeOptions options = new ChromeOptions();
var proxy = new Proxy();
proxy.Kind = ProxyKind.Manual;
proxy.IsAutoDetect = false;
proxy.HttpProxy = proxyUrl;
proxy.SslProxy = proxyUrl;
options.Proxy = proxy;
options.AddArgument("ignore-certificate-errors");
IWebDriver driver = new ChromeDriver(service, options);
int waitTime = GetRandomWait2to5.getRandom2to5();
driver.Url = "https://whatismyipaddress.com/"; //TEST
============ END ========================= See attached screenshot with "local connections allowed". Passing "chrodriver --whitelisted-ips=''" in CMD works and says "all remote connections allowed". Thanks for the input. (edited)
CodePudding user response:
When you instantiate ChromeDriver a Chrome driver executable is launched, you need to pass --whitelisted-ips=''
using options.AddArgument("--whitelisted-ips=''")
In your case:
ChromeDriverService service = ChromeDriverService.CreateDefaultService();
service.WhitelistedIPAddresses = ""; // NOTE: The idea is to allow all remote
connections. How to allow all IPs?
service.Port = 9515;
ChromeOptions options = new ChromeOptions();
var proxy = new Proxy();
proxy.Kind = ProxyKind.Manual;
proxy.IsAutoDetect = false;
proxy.HttpProxy = proxyUrl;
proxy.SslProxy = proxyUrl;
options.Proxy = proxy;
options.AddArgument("ignore-certificate-errors");
options.AddArgument("--whitelisted-ips=''"); // NEW LINE ADDED
IWebDriver driver = new ChromeDriver(service, options);
int waitTime = GetRandomWait2to5.getRandom2to5();
driver.Url = "https://whatismyipaddress.com/"; //TEST
CodePudding user response:
Ok, that was way simpler than i thought: Replace service.WhitelistedIPAddresses = ""
with service.WhitelistedIPAddresses = " "
. This finally shows "All remote connections are allowed".