1

I am creating a bot that goes to a website, changes proxy, and then reloads the website. I want the update the proxy for the chrome web driver in the loop, but I only found a way to do it if I create a new web driver with a new proxy. I only want to update the current chrome drivers proxy, not create a new one with a new proxy.

            IWebDriver driver;
            for (int i = 0; i < listBoxNames.Items.Count; i++)
            {
                ChromeOptions settings = new ChromeOptions();
                Proxy Proxy = new Proxy();
                Proxy.Kind = ProxyKind.Manual;
                Proxy.IsAutoDetect = false;
                Proxy.SslProxy = Proxies[i];
                settings.Proxy = Proxy;
                settings.AddArgument("ignore-certificate-errors");
                driver = new ChromeDriver(settings);
            }

This code creates a new web driver every time it cycles through the loop. How can I make it so it only updates a new proxy to the current web driver instead?

Umang
  • 815
  • 5
  • 17
Larches
  • 51
  • 7
  • When you call `new ChromeDriver()`, it creates a new browser instance. You can't change the proxy without updating `ChromeOptions` which requires a new call to `new ChromeDriver()` to get the changes which then creates a new browser instance. – JeffC Sep 16 '20 at 03:33

0 Answers0