Delete Browser Cookie, Cache, and History in UFT

What is Browser Cache

Whenever we browse a website, the information on the websites is cached in a temporary storage location on our computer for files downloaded by our browser to reduce the page loading time next time the website is browsed. The file includes HTML pages, images, CSS style sheets, and JavaScript scripts.

delete browser cookie and History in UFT

What is Browser Cookie

A cookie is a small piece of information that is sent by the webserver to your browser when you visit a website. The browser stores these pieces of information in a small file called Cookie.txt.Cookies were designed to remember various information like items added in the shopping cart in an online store or to record the user’s browsing activity. Cookies are also be used to remember the user’s data previously entered into form fields such as usernames, passwords, email id, addresses, and credit card numbers, etc.

Delete browser Cookies in UFT using WebUtil

We can use the DeleteCookies method available under the WebUtil class to delete cookies for the IE browser.
Write the following code to delete all cookies for IE browser.

Delete Cookies for a Domain on IE Browser

We can use DeleteCookies method on a browser object to delete all cookies of the browser.
object.DeleteCookies [FromSource]
 Parameter    Description
 FromSource                             Optional. A String value.
 The full or partial domain of the source. For example, entering or clears cookies only from the specified site, and entering MySite clears
 cookies from all related domains.
 Default value = “”


Clear Cache from the browser in UFT

To clear cache from the browser use the following code.

Clear IE Cache, Cookie & History Using VBA/Shell Scripting

Use the following code for the following purposes.

Delete History From Chrome and Mozilla Firefox

The above-discussed method will not work for a web browser other than IE. To clear history from other browsers use the following workaround.

Use keyboard shortcut Ctrl + Shift + Delete to invoke the Clear History/Browsing dialog box. Once the dialog box is displayed, write the automation code to delete whatever data you want.

Use the following code to invoke the History/Browsing dialog box.

Recommended Posts

Leave a Reply