title: Selenium how to clear cache using chromedriver and C#
body: <p>I found Java examples that explain that clearing the cache is as simple as this:</p>
  
  <p>Sample Code:</p>
  
  <pre><code>System.setProperty("webdriver.chrome.driver","drivers/chromedriver.exe");
  
          DesiredCapabilities capabilities = DesiredCapabilities.chrome();
          capabilities.setCapability(CapabilityType.ForSeleniumServer.ENSURING_CLEAN_SESSION, true);
  
          ChromeOptions opts = new ChromeOptions();
          opts.addArguments("start-maximized");
          capabilities.setCapability(ChromeOptions.CAPABILITY, opts);
  
          WebDriver driver = new ChromeDriver(capabilities);
          driver.manage().deleteAllCookies();
          driver.get("http://www.google.com");
          System.out.println(driver.getTitle());
          driver.quit();
  </code></pre>
  
  <p>I attempted to do the same in C# 4.6 and Selenium WebDriver 2.45, but DesiredCapabilities does not contain an enum or string for ENSURING_CLEAN_SESSION. I do not understand why the C# version would not have the same options available as the java version. My hunch is that there is a trick, such as directly using a string that represents the same capability that is available in java as an enum, I'm just not sure what it is.</p>
  
  <p>Here is my code:</p>
  
  <p>// The SetCapability(..) method call is meaningless...</p>
  
  <pre><code>var chromeDriverService = ChromeDriverService.CreateDefaultService();
                  chromeDriverService.HideCommandPromptWindow = true;
  
                  DesiredCapabilities capabilities = DesiredCapabilities.Chrome();
                  capabilities.SetCapability(ChromeOptions.Capability, true); // ? can't set ENSURING_CLEAN_SESSION, intellisense shows it does not exist
  
                  var options = new ChromeOptions();
  
                  options.AddArguments("test-type");                  
  
                  return new ChromeDriver(chromeDriverService, options);
  </code></pre>