title: Selenium how to change browser settings during the process
body: <p>When the browser starts, the proxy settings are successfully installed.</p>
  
  <pre><code>FirefoxOptions options = new FirefoxOptions();
  
  options.SetPreference("network.proxy.http", proxy);
  options.SetPreference("network.proxy.http_port", port);
  
  options.SetPreference("network.proxy.ftp", proxy);
  options.SetPreference("network.proxy.ftp_port", port);
  
  options.SetPreference("network.proxy.ssl", proxy);
  options.SetPreference("network.proxy.ssl_port", port);
  
  options.SetPreference("network.proxy.socks", proxy);
  options.SetPreference("network.proxy.socks_port", port);
  
  options.SetPreference("network.proxy.type", 1);
  IWebDriver driver = new OpenQA.Selenium.Firefox.FirefoxDriver(options);
  </code></pre>
  
  <p>But I need to be able to change them during execution, without restarting the browser. Internet search has not brought anything. Interested in any ways to solve the problem, not only by means of Selenium</p>
  
  <p>I already wrote a function that allows you to change non-boolean Preferences. Here it is</p>
  
  <pre><code>void SetPreference(string preferenceName, string value, IWebDriver driver)
          {
              IJavaScriptExecutor js = (IJavaScriptExecutor)driver;
              js.ExecuteScript($"document.getElementById(\"textbox\").value = '{preferenceName}'");
              js.ExecuteScript("FilterPrefs()");
              js.ExecuteScript("view.selection.currentIndex = 0");
              js.ExecuteScript("ModifySelected();");
  
              IAlert alert = driver.SwitchTo().Alert();
              alert.SendKeys(value);
              alert.Accept();
          }
  </code></pre>
  
  <p>I can also change boolean preferences, but i can't read value what already written. I can only change value on the opposite. How i can read preference value? To know whether to change it or not.</p>
  
  <pre><code>void ChangeBoolValue(string preferenceName, IWebDriver driver)
          {
              IJavaScriptExecutor js = (IJavaScriptExecutor)driver;
              js.ExecuteScript($"document.getElementById(\"textbox\").value = '{preferenceName}'");
              js.ExecuteScript("FilterPrefs()");
              js.ExecuteScript("view.selection.currentIndex = 0");
              js.ExecuteScript("ModifySelected();");
          }
  </code></pre>