Have you ever wondered about how to effortlessly transfer your QTP scripts from your computer to one of colleagues or may be from a drive of your computer to another ? Well, relative path is the answer. As promised in my previous post on optimizing QTP scripts, we “ll discuss what is a relative path and the benefits of using them in your QTP scripts.
There can be two types of path in your file System, absolute and relative.
A full path or absolute path is a path that points to the same location on one file system regardless of the working directory.
Example of a full path:
C:Program FilesMercury InteractiveQuickTest ProfessionalTests

while

A relative path is a path relative to the current working directory, so the full absolute path may not need to be given.
Example of a relative path: Say your current working directory is QuickTest Professional asshown above so the relative path for the folder Mercury Interactive which is one level up would be ….Mercury Interactive similarly folder which is on same level can be referenced by ..Some Folder
Now that the definition is clear, I think you can guess the benefits of using relative paths in QTP.
Suppose you have a test where you need to call a reusable action which was created in a different test. The normal steps we follow would be: Insert > Call to existing Action

Call to existing action
and then we select the reusable action from the drop down list.

Select Action

The major drawback with this approach is that if you need to shift your files to some other computer where the similar path is not maintained you will have to do a lot of rework and map the reusable actions all again.
To get over this problem, we can use relative path. In the Select Action box as shown below instead of selecting the test just type in ..Test1. If there is a test named “Test1” in the current directory, action drop down box would automatically populate the list of reusable actions under it.

Select Action from Test
References: Wiki: Path