title: C# Set default download directory chrome WebDriver?
body: <p>This is my solution, based on <a href="https://stackoverflow.com/questions/15824996/how-to-set-chrome-preferences-using-selenium-webdriver-net-binding">this question</a></p>
  <p>But it's not working, I need to change the default download directory for google chrome to</p>
  <blockquote>
  <p>C:\temp\</p>
  </blockquote>
  <p>Thanks for the help.</p>
  <pre class="lang-cs prettyprint-override"><code>public class ChromeOptionsWithPrefs : ChromeOptions
  {
      public Dictionary&lt;string, object&gt; prefs { get; set; }
  }
  
  public static void Initialize()
  {
      var options = new ChromeOptionsWithPrefs
      {
          prefs = new Dictionary&lt;string, object&gt;
          {
              {&quot;download.default_directory&quot;, @&quot;C:\temp\&quot;}
          }
      };
      
      RemoteWebDriver driver = new ChromeDriver(@&quot;D:\chromedriver_win32\&quot;, options);
      
      var download = driver.FindElements(By.XPath(&quot;//a[.='Download']&quot;));
      
      foreach (var t in download)
      {
          t.SendKeys(Keys.Enter);
      }
  }
  </code></pre>
  <p>I found this solution, it worked</p>
  <pre class="lang-cs prettyprint-override"><code>var chromeOptions = new ChromeOptions();
  
  chromeOptions.AddUserProfilePreference(&quot;download.default_directory&quot;, @&quot;D:\DataTest&quot;);
  chromeOptions.AddUserProfilePreference(&quot;intl.accept_languages&quot;, &quot;nl&quot;);
  chromeOptions.AddUserProfilePreference(&quot;disable-popup-blocking&quot;, &quot;true&quot;);
  
  var driver = new ChromeDriver(@&quot;D:\chromedriver_win32\&quot;, chromeOptions);
  
  var download = driver.FindElements(By.XPath(&quot;//a[.='ダウンロード']&quot;));
  
  foreach (var t in download)
  {
      t.SendKeys(Keys.Enter);
  }
  </code></pre>