Selenium WebDriver Java Framework Course Limited Time Offer for $20

Selenium WebDriver Java Framework Course Limited Time Offer for $20

 

Home

Print

How to Clear Browser Cookies with Selenium Web Driver

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.

}
  • All
  • .NetWebDriver
  • C#CodeTutorial
  • C#WebDriver
  • JavaCodeTutorial
  • NodeJSSeleniumWebDriver
  • NodeJSWebDriver
  • PerformanceTest
  • PythonWebDriver
  • RegularExpressionTutorial
  • RubySeleniumWebDriver
  • SeleniumAppiumMobileTest
  • SeleniumAutomationInterview
  • SeleniumGrid
  • SeleniumIDE
  • SeleniumJavaWebDriver
  • SeleniumMobileTest
  • SeleniumPerformanceTest
  • SeleniumPythonRobotFramework
  • SeleniumRC
  • SeleniumRobotFramework
  • SQLForTester
  • Default
  • Title
  • Date
  • Random