relative path

Best practices, code snippets for common functionality, examples, and guidelines.
IvanT
Posts: 40
Joined: Wed Feb 06, 2019 8:00 pm

relative path

Post by IvanT » Sun Dec 22, 2019 8:07 pm

Could someone tell me how to use relative path to file in ranorex?

foals11
Posts: 20
Joined: Wed Sep 18, 2019 9:19 am

Re: relative path

Post by foals11 » Mon Dec 23, 2019 2:43 pm

Hi,

Can you explain in detail, what do you want to achieve?

If you want to include files into Ranorex, follow these steps. First of all, you have to include the file into the project folder (in my case an excel file). Afterwards, right-click the file in Ranorex Studio and click "Include in project". When the file is included, open the properties and set "Copy to output directory" to "Always".

See my attached screenshots, to comprehend the steps which have been made.

regards,
Attachments
Step3.png
Step3.png (75.03 KiB) Viewed 504 times
Step2.png
Step2.png (43.6 KiB) Viewed 504 times
Step1.PNG
Step1.PNG (37.33 KiB) Viewed 504 times

IvanT
Posts: 40
Joined: Wed Feb 06, 2019 8:00 pm

Re: relative path

Post by IvanT » Mon Dec 23, 2019 9:38 pm

Thanks. it is ussefull to me.
i mean that i have string = path to file witch is in currently project.
for example file in directory C:/Program file/project/filesForTesting/name.txt
i think that instead full path to file i can use short path like /filesForTesting/name.txt

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 6360
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: relative path

Post by odklizec » Fri Dec 27, 2019 9:08 am

Hi,

You can use this code, to return the actual working directory, from which is started your test:

Code: Select all

string getActualDir = TestSuite.WorkingDirectory.ToString();
Then simply add whatever you want at the end of found path (e.g. like this):

Code: Select all

string getDataDir = getActualDir + "\\Data\\file.txt";
or with variable, containing relative path to file:

Code: Select all

string getDataDir = getActualDir + relPathToFile;
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

Worker
Posts: 3
Joined: Tue Oct 22, 2019 1:21 pm

Re: relative path

Post by Worker » Fri Dec 27, 2019 11:02 am

thank you, i'll try