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.


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

WebDriver driver = new ChromeDriver();

You can also delete the cookies one by one

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

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

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