Cookies are those small files on your computer that store information between sessions or between two login attempts. There are valid reasons where you might need to delete cookies stored on your computer through scripting.

Now, how can we delete cookies through VB ScriptinDelete cookiesg in QTP? This one is a very often repeated question on the testing tools forums. I will first provide a hint here.

  1. You need to write a custom function to do this. IMHO there is no direct way available.
  2. Write a shell script to reach to the cookies file residing in your corresponding folder.
  3. Delete all the files inside that folder.

Please post your script in the comments below. If I don’t get an answer by tomorrow, I will update the post with my script.

Answer: Use WebUtil.DeleteCookies whenever you want to delete cookies from IE.

Update: As pointed by Paul on LearnQTP feedback forum, we now have some other methods as well to delete cookies/browser cache.

To clear Cache from the browser

Browser("Page Title").ClearCache

To delete Cookies from the browser

Browser("").DeleteCookies "Google"

The above code will delete cookies for ALL Google domains like,,  If you wish to remove cookies for a specific domain use the corresponding Top Level Domain

Browser("").DeleteCookies ""

There are interesting methods posted in the comments section below, don’t forget to check those.