In Our application while testing Manually we clear Cookies (Ctrl+Shift+Del), How can I automate this step?

Note: We are using Java


You can delete cookies using cookiename and all cookies alltogether.

To delete a particular cookie , use this


Python version of this method is


To delete all cookies at once


Python version for the same above is


These are same for all browsers.

  • A small warning is that these look like non blocking methods - stackoverflow.com/questions/27504358/… – John Nov 21 '16 at 13:51
  • Also, deleteAllCookies will only delete cookies under the domain of currently opened page. – Kenston Choi Jan 3 '17 at 7:36
  • @KenstonChoi Yes, right!! How to delete from other domains as well?? – Pranav Bilurkar Apr 7 '17 at 9:10
  • @Pranav-BitWiser, some sites suggest that the browser has to visit these domains individually and delete the cookies. The easiest is to just launch a new browser session. – Kenston Choi Apr 7 '17 at 11:07
  • @KenstonChoi Does this means that launching a new session will automatically deletes all cookies? – Pranav Bilurkar Apr 7 '17 at 13:25

You can use Selenium methods to clear the cookies.Here is the example

  • Is this Same for all Browsers? – Tom J Muthirenthi Feb 15 '16 at 7:21
  • 1
    yup, same for all for browsers – QAMember Feb 15 '16 at 7:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.