{"id":26819,"date":"2018-02-22T05:35:35","date_gmt":"2018-02-22T05:35:35","guid":{"rendered":"https:\/\/www.testingdocs.com\/questions\/?p=26819"},"modified":"2025-05-17T07:31:08","modified_gmt":"2025-05-17T07:31:08","slug":"how-to-delete-cookies-in-selenium","status":"publish","type":"post","link":"https:\/\/www.testingdocs.com\/questions\/how-to-delete-cookies-in-selenium\/","title":{"rendered":"How to delete Cookies in Selenium"},"content":{"rendered":"<h1>How to delete Cookies in Selenium<\/h1>\n<p>Users can delete the named cookie from the current domain. This is equivalent to setting the named cookie&#8217;s expiry date to sometime in the past.\u00a0Users can also delete all the cookies for the current domain using the <strong>driver.manage().deleteAllCookies() <\/strong>method.<\/p>\n<h2>Examples<\/h2>\n<p>Deleting the specific cookie with the cookie name &#8220;foo&#8221;<\/p>\n<pre><code class=\"\" data-line=\"\">@Test\n\tpublic void deleteCookieNamedExample()\n\t{\n\t\tdriver= new FirefoxDriver();\n\t\tString URL=&lt;span class=&quot;hljs-string&quot;&gt;&quot;&lt;\/span&gt;&lt;span class=&quot;hljs-string&quot;&gt;https:\/\/www.example.com&quot;&lt;\/span&gt;;\n\t\tdriver.navigate().to(URL);\n\t\tdriver.manage().deleteCookieNamed(&lt;span class=&quot;hljs-string&quot;&gt;&quot;foob&quot;&lt;\/span&gt;);\n\t}<\/code><\/pre>\n<p>Deleting all the cookies of the domain<\/p>\n<pre><code class=\"\" data-line=\"\">@Test\n\tpublic void deleteAllCookiesExample()\n\t{\n\t\tdriver= new FirefoxDriver();\n\t\tString URL=&lt;span class=&quot;hljs-string&quot;&gt;&quot;&lt;\/span&gt;&lt;span class=&quot;hljs-string&quot;&gt;https:\/\/www.example.com&quot;&lt;\/span&gt;;\n\t\tdriver.navigate().to(URL);\n\t\tdriver.manage().deleteAllCookies();\n\t}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>How to delete Cookies in Selenium Users can delete the named cookie from the current domain. This is equivalent to setting the named cookie&#8217;s expiry date to sometime in the past.\u00a0Users can also delete all the cookies for the current domain using the driver.manage().deleteAllCookies() method. Examples Deleting the specific cookie with the cookie name &#8220;foo&#8221; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[185],"tags":[],"class_list":["post-26819","post","type-post","status-publish","format-standard","hentry","category-selenium","has-post-title","has-post-date","has-post-category","has-post-tag","has-post-comment","has-post-author",""],"_links":{"self":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/26819","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/comments?post=26819"}],"version-history":[{"count":6,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/26819\/revisions"}],"predecessor-version":[{"id":27429,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/26819\/revisions\/27429"}],"wp:attachment":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/media?parent=26819"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/categories?post=26819"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/tags?post=26819"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}