Micro Focus QTP (UFT) Forums

Full Version: programmatically clear cache
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,
Is there a way to programmatically clear cache in QTP ?
I'm dealing with a Webapp, and I use webutil.deletecookies to clear cookies. Anything for clearing cache?

Thanks,
Monika
Hi,
Is it working fine? we also having so many problems regarding
cookies.
Instead of clearing cache everytime , you can set a one time option of disabling cache from Tools > Internet options > Temporary Internet Files and set the amount of disk space =1 .
Since IE 6 requires the cache space to be greater than 1 MB no pages will be stored from now on.
Code:
Sub DeleteCache()
Dim root
Set root = CreateObject("FPC.Root")
Dim server
Dim cacheDrives
Dim cacheDrive
Dim fso
Set server = root.GetContainingServer()
server.StopFirewallService()
Set cacheDrives = server.CacheDrives
Set fso = CreateObject("Scripting.FileSystemObject")
For Each cacheDrive In cacheDrives
    cacheFilePath = CacheDrive.Name & "\urlcache\Dir1.cdat"
    fso.DeleteFile cacheFilePath
Next
server.StartFirewallService()
End Sub