The PathFinder
object is useful to find a file or folder in the folders listed in the UFT search list. The method Locate
returns a string with the path found. Other methods, which are rather undocumented, can be used to manage the list of search folders using code, but they are beyond the scope of this book.
From the File menu, navigate to New | Test, or use the Ctrl + N shortcut. In the Tools menu, select Options. In the dialog that opens, navigate to GUI Testing | Folders and add one folder or more to the search list.
To get the path of a file, use the following syntax:
sFilePathname = PathFinder.Locate("MyFile.txt")
The PathFinder.Locate
method will search through the folders listed in the search list according to their order and, if found, return the full pathname. It will return the first instance found. This means, if more than one file with the searched name exists in the several folders, the method will proceed based on the priority of the folders.