Absolute and Relative Paths in QTP

Hello Friends,
In this post, we will learn how to make life easy using Relative Paths!!
First thing first..
What is Absolute Path?
Suppose you have a qtp test stored at “C:MyQTPProjectrelease1MainTest”
You have some external actions, shared object repository, function libraries, recovery scenarios and data files stored in different folders in above path..
your external action is in – “C:MyQTPProjectrelease1MainTestCallTestAction1”
your OR is in – “C:MyQTPProjectrelease1MainTestOR”
your Lib is in – “C:MyQTPProjectrelease1MainTestLib”
and so on..
When you attach all these recourses to you test, you can do it by using either Absolute path or relative path.
By default we use Absolute path.
General steps we follow are, Go to – Insert >> Call to existing Action >> Select Path >> select the reusable action from the drop down list.
Here the path we will select is – “C:MyQTPProjectrelease1MainTestCallTest” as our external action is stored here. This is Absolute path.
What is Relative Path and why I need this?
Now suppose you need to move (cut & paste) you folder to some different location/machine!
When you move your folder, all the Absolute paths mentioned above will not be found as path will not exist.
If you try to run your test, you will see missing recourse error. To make it work you need to do a lot of rework which sucks!
Here we need something like – Relative Paths!!!
How to use Relative Paths?
Instead of giving full/absolute path, we can use relative paths.
Go to – Insert >> Call to existing Action >>

In “From Test” , instead of browsing to path, simply type – “..CallTest” (without quotes) and all reusable action will be displayed in drop down list.
Same process for function lib, object repository etc.
Now even if you folder has been moved, you don’t need to do any extra effort. Life is easy!! 🙂

2 thoughts on “Absolute and Relative Paths in QTP”

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top