How to delete browser cookies in QTP?

Web applications uses cookies to store user related information. While testing these cookies might interfere with the results of test. It is recommended to delete cookies before starting new test.

In this article we will see how to delete cookies for a browser. Different browser stores cookies in different places and in different format.

Deleting IE Cookies

IE cookies can be deleted using WebUtil object which comes with QTP. We need to use the DeleteCookies method as shown in the code below

The code above is compatible from QTP 8.2 and higher. For versions lower than QTP 8.2, we need to modify the code a bit

WebUtil only works with IE and we can’t delete Firefox cookies using this

Deleting Firefox Cookies

Firefox stores all it cookies in a Cookies.txt file. This file gets stored in the user profile and has different location for different operating system. We won’t created the function for locating the cookies, but we will assume that the path is already known to us

GetFFCookiesPath is the function which locates the path for cookies.txt on various windows platform. I have implemented the GetFFCookiesPath function for Windows Vista, one would need to add handling in

Have questions related to this article? Want to request a new article? Use our forums to post your questions

  1. Suscribe to Email

    Enter your email address:

    Delivered by FeedBurner