There is no straightforward way to clear cookies in Firefox through QTP. Using sendkeys to simulate how we do it manually seemed ridiculously out of the question, so I came up with the following code after doing some research :-
Set FSO = CreateObject(“Scripting.FileSystemObject”)
Set oShell = CreateObject(“WScript.Shell”)
sUserProf = oShell.ExpandEnvironmentStrings(“%USERPROFILE%”) & “\AppData\Roaming\Mozilla\Firefox\Profiles”
If FSO.FolderExists(sUserProf) Then
Set oFolder = FSO.GetFolder(sUserProf)
If oFolder.SubFolders.Count> 0 Then
‘oFolder.item(0) throws an error, so we use a workaround to find the first folder
For each oFolder in oFolder.SubFolders
sPath = oFolder.Path
For each afile in FSO.GetFolder(sPath).Files
On Error Resume Next
If Instr(extension,”sqlite”)>0 and Instr(afile.name,”cookies”)>0 Then
On Error Goto 0
Please note that firefox should be closed in order for this code to execute. This code can also be written in a plain vbs file and executed directly without QTP.
Happy Automating !