relative path

Best practices, code snippets for common functionality, examples, and guidelines.
IvanT
Posts: 51
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,
You do not have the required permissions to view the files attached to this post.

IvanT
Posts: 51
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: 7470
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

testerad
Posts: 2
Joined: Wed Feb 01, 2023 10:52 am

Re: relative path

Post by testerad » Mon Feb 20, 2023 3:42 pm

1. For csv and xls files relative path is recognized by Ranorex:
pic1.png
pic2.png
2. where for mdb files only physical path is recognized by Ranorex:
pic3.png
Relative path for connection string brings errors:
e.g. if file name = \mdbFiles\SNWX-Produkte.mdb

Is short path (relative path) for Access.mdb file possible at all?
How to achieve that?

thank you
You do not have the required permissions to view the files attached to this post.