This code below applies to Selenium .Net.
Clearing browser cookies before starting your test is important to test the application in real life scenarios. If you are using Selenium Web Driver for your web test automation, you can use this method below to clear all cookies.
Let's assume that your Selenium Web Driver name is _webDriver; You can create a void method below and then call the method before you navigate to the application URL.
- public void ClearBrowserCache()
- { _webDriver.Manage().Cookies.DeleteAllCookies(); //delete all cookies
- Thread.Sleep(5000); //wait 5 seconds to clear cookies. }