2

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)

phi1618
  • 47
  • 1
  • 1
  • 3

2 Answers2

1

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
Mike93041
  • 359
  • 1
  • 9
  • I already did that as you can see, and it doesnt do it. The right way/ ot other way to do it to trough using the service.WhitelistedIPAddresses="", where == Ips to be allowd. The main question to me is, how exactly i pass the as a parameter? – phi1618 Jan 04 '23 at 21:44
  • 1
    [WhitelistedIPAddresses](https://www.selenium.dev/selenium/docs/api/dotnet/html/P_OpenQA_Selenium_Chrome_ChromeDriverService_WhitelistedIPAddresses.htm) can't be set to if set to an empty string only the local loopback address can connect. Please recheck carefully my answer and the new line just before ChromeDriver instantiation, you didn't do that. Also you can have a look to [this](https://stackoverflow.com/questions/40305669/selenium-webdriver-3-0-1-chromedriver-exe-2-25-whitelisted-ips) post which is pretty similar if not identical only it's java. – Mike93041 Jan 04 '23 at 21:57
  • yes, i have tried that, and other variations of it, such as: //options.AddArgument("whitelisted-ips=''"); //options.AddArguments("whitelisted-ips=''"); //options.AddArguments("allowed-ips=''"); //options.AddArguments("allowed-origins=''"); //options.AddArguments("whitelisted-ips=''"); options.AddArgument("--whitelisted-ips=''"); Nove of these work. Also i have seen the post you are refrring to. C# ChromeOptions Class has only "ReadOnlyDesiredCapabilities" class – phi1618 Jan 04 '23 at 22:11
  • 1
    Have you tried these variations without `service.WhitelistedIPAddresses = ""`? – Mike93041 Jan 04 '23 at 22:15
  • Yes, initially i just used the "options.AddArgument("--whitelisted-ips=''");" line, but sisnce could nt make it work, i looked into using "ChromeDriverService" Class. Also, i have used only "options.AddArgument("--whitelisted-ips=''")" – phi1618 Jan 04 '23 at 22:24
0

Ok, that was way simpler than i thought: Replace service.WhitelistedIPAddresses = "" with service.WhitelistedIPAddresses = " ". This finally shows "All remote connections are allowed".

phi1618
  • 47
  • 1
  • 1
  • 3