Forum Discussion
Kitt
3 years agoRegular Contributor
Groovy scripts have full access to the object model in ReadyAPI, not TestComplete. You might want to try that community forum [here] for Groovy specific scripts.
You can accomplish this in TestComplete by using the aqFileSystem object and searching through all files within a folder. Below is a working example which counts the number of files in the folder (for reference) then iterates through every file searching for the specified 'aSubString' and prints the name of the file to the log when the 'aSubString' is found.
function findStringInFolderFiles() {
var file;
var folderPath = "C:\\your\\folder\\path";
var folderObject = aqFileSystem.GetFolderInfo(folderPath);
var folderItems = folderObject.Files;
var aSubString = "Replace"; // string to search for
Log.Message("Found " + folderItems.Count + " files in " + folderPath);
while (folderItems.HasNext()) {
file = folderItems.Next();
var fullPath = folderPath + "\\" + file.Name;
var str = aqFile.ReadWholeTextFile(fullPath, aqFile.ctANSI);
var res = aqString.Find(str, aSubString);
if (!equal(res, -1)) {
Log.Checkpoint(file.Name);
}
else {
Log.Message("NOT FOUND: There are no occurances of " + aSubString + " in " + fullPath);
}
}
}
You should be able to apply the same logic to your Groovy scripts. These references may provide a good starting point: [read files w/Groovy] and [search files w/Groovy].
Related Content
- 3 years ago
- 3 years ago
- 5 years ago
Recent Discussions
- 6 days ago
- 6 days ago
- 10 days ago