Forum Discussion
TanyaYatskovska
Alumni
12 years agoHi Alina,
In my opinion, there is no need to use the Windows Explorer window for this. You can use special methods that allow working with files and folders. For example, the script below gets all subfolders inside the specified folder and posts their names to the Test Log (taken from this article):
//JScript
function SubFoldersFinder()
{
// Specifies the path to the desired folder
var sPath = "C:\\MyFolder";
// Obtains information about the folder
var FolInfo = aqFileSystem.GetFolderInfo(sPath);
// Obtains the collection of subfolders
var colSubFolders = FolInfo.SubFolders;
// Checks whether the collection is not empty
if (colSubFolders != null)
{
// Posts the names of the folder's subfolders to the test log
Log.AppendFolder("The " + sPath + " folder contains the following subfolders:");
while (colSubFolders.HasNext())
{
// Obtains the current subfolder
var FolItem = colSubFolders.Next();
// Posts the subfolder's name to the test log
Log.Message(FolItem.Name);
}
Log.PopLogFolder();
}
else
Log.Message("The specified folder does not contain any subfolders.");
}