I created a 4test script to test our web based application and would like to know how to delete a specific cookie file during script execution?
The following 4test function can be used for deleting specific cookie file:
[-] RemoveCookies (String sPath, String sFile)
[ ] //*******************
[ ] //* The function for removing a stored web cookie file.
[ ] //* sPath The complete path to the directory where the cookie is stored
[ ] //* Example "C:\Documents and Settings\Administrator\Cookies\"
[ ] //* sFile unique part of the cookie file name
[ ] //* for example "*winrunner*"
[ ] //*******************
[ ] LIST OF FILEINFO lfInfo
[ ] LIST OF STRING lsFileName
[ ] INTEGER iCount
[ ] STRING sLFile
[ ] Boolean bFound
[ ]
[ ] lfInfo = SYS_GetDirContents (sPath) //obtain directory content
[-] for iCount = 1 to ListCount(lfInfo) //for every FILEINFO in lsInfo
[ ] ListAppend(lsFileName, lfInfo[iCount].sName) //append the name of the files
[ ]
[-] for each sLFile in lsFileName //for each file name in lsFileName
[ ] bFound = MatchStr (sFile, sLFile) //check if the sFile string is in the File Names
[-] if bFound == TRUE //if the sFile string is in file name
[ ] SYS_RemoveFile (sPath + sLFile) //delete the file from the sPath directory
[ ]
You can easily modify this 4test function to remove all files in the particular directory or within a loop delete a list of files.