Thursday, September 29, 2011

QTP Codes blog is being updated

QTP Codes blog is being updated. You will see post design changes shortly.

More Methods For PathFinder Object

Most of us are aware of the Locate method available for PathFinder object. But there are more useful and unfamiliar methods associated with PathFinder Object. I would like to share how these methods can be used in QTP.

# INSERT
Description:
This method is used to add a new folder path to the Folders list (Tools-> Options-> Folders).

Syntax:
PathFinder.Insert [Path],[Index]
Example:
PathFinder.Insert "C:\Test",0
The above example will add new folder path to the Folders list.

# FIND
Description:
This method returns the Index of the specified path.

Syntax:
Msgbox PathFinder.Find [Path]
Example:
Msgbox PathFinder.Find("C:\Test")
The above example returns the Index of the specified path. If the path is not found, it will return -1.

# MOVEITEM
Description:
This method can be used to swap the Index of two folder paths.

Syntax:
Pathfinder.MoveItem [Source_Index],[Destination_Index]
Example:
Pathfinder.MoveItem 1,0

# REMOVE
Description:
This method removes the specified folder path from the folders list.

Syntax:
Pathfinder.Remove [Path]
Example:
Pathfinder.Remove("C:\Test")

# REMOVEALL
Description:
This method removes all the items from the folders list.

Syntax/Example:
Pathfinder.RemoveAll
Note: It removes default folder item as well.

# REMOVEBYINDEX
Description:
This method removes the folder path item using Index.

Syntax:
PathFinder.RemoveByIndex([Path_Index])
Example:
PathFinder.RemoveByIndex(0)

# SAVE
Description:
This method can be used to commit all the changes which are done using PathFinder object. If Save method is not used, your changes in Folder List will not be retained.

Syntax/Example:
PathFinder.Save