Micro Focus QTP (UFT) Forums
Relative Path problem - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: Relative Path problem (/Thread-Relative-Path-problem)



Relative Path problem - Kakashi - 02-15-2012

Hi,
I am trying to use the relative path in qtp to open a excel file to take input from and maintaining a definite folder structure. But on using this function
getabsolutepath in qtp gives C:\Program Files\HP\QuickTest Professional\bin
as my current working directory. How to use my script path as the current working directory, I have tried added the path in Tools->Options->Folder but it sometimes open C:\Program Files\HP\QuickTest Professional\bin as my current working directory.
Thanks


RE: Relative Path problem - inborntester - 02-15-2012

Code:
TestDir=Environment.Value("TestDir")
TestNameLength=Len(Environment.Value("TestName"))
TestDir=Left(TestDir,Len(TestDir)-TestNameLength)
Set excel = CreateObject("Excel.Application")
InitFilePath=TestDir+"\Init\Init.xls"
Set workbook = excel.Workbooks.Open(InitFilePath)
Set worksheet=workbook.Worksheets("Sheet1")
Set url = worksheet.Cells.Find("url")
urladd= worksheet.Cells(url.row,(url.column)+1)
excel.Quit
SystemUtil.Run urladd

my test directory(folder) is "Test" and am having a folder named "Init" beside my test folder. there i am having a excel file "Init.xls" to store url of the application. i read it using the above code. the idea is, i have used the
predefined environment variable "TestDir" for my logic.