Clear browser Cookies with Selenium WebDriver Java bindings

Does anyone know if it’s possible to Clear Browser Cookies for WebDriver before starting the automation? (Note: Not Selenium RC)

Yes, it’s possible.

driver.manage().deleteAllCookies();

Call it right after you are creating the new WebDriver instance.

WebDriver driver = new ChromeDriver();
driver.manage().deleteAllCookies();

You can also delete the cookies one by one

Set<Cookie> allCookies = driver.manage().getCookies();
for (Cookie cookie : allCookies) {
    driver.manage().deleteCookieNamed(cookie.getName());
}

ChromeDriver provides a way to clear cookies of all websites/domains:

driver.ExecuteChromeCommand("Storage.clearCookies", new Dictionary<string, object>())