Utility Objects


1. The Crypt Object:
This object encrypts strings in a format that the QTP SetSecure function understands

myVar=Crypt.Encrypt(“mercury”)
msgbox myVar

2. The OptionalStep object:
This object is used to make a statement optional in situation where the statement might fail.

     OptionalStep.Window(“Flight Reservation”).WinButton(“Insert Order”).click

3. The pathfinder Object
This object is used to find the absolute path to a file. 

Through navigation: QTP allows setting folder paths in the Tools OptionsFolders
During run time: 
Msgbox  PathFinder.Locate(“<path of the file to be searched>”)

4. The RandomNumber object:
This object provides a method to get a random number between two specified values.
Msgbox RandomNumber(1,100)

5. The SystemUtil object:
This object is used to run and close process. Below are few examples of starting process;

‘Run internet explorer
SystemUtil.Run “iexplore.exe”

‘Run internet explorer and pass the starting URL
SystemUtil.Run “iexplore.exe”, http://www.gmail.com

Contributed by: Vamshi Gowtham
m.vamsigowtham@gmail.com