Path to project directory

Ask general questions here.
Mayra
Posts: 68
Joined: Mon Dec 16, 2013 5:27 am

Path to project directory

Post by Mayra » Mon Mar 03, 2014 11:41 pm

Hi,
I have been looking in the API for a current project directory but I can not find something like that.
Where can I look?
Thanks

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Path to project directory

Post by Support Team » Wed Mar 05, 2014 10:28 am

Hi Mayra,

Unfortunately there is no direct method to get the path of the project folder.

There is the possibility to use this little workaround:

Code: Select all

string path = Ranorex.Core.Testing.TestSuite.WorkingDirectory; //Returns the path to the Bin/Debug Folder of your project
string parentpath = Directory.GetParent(path).ToString(); //returns the path to the Bin/ Folder of your project
string grandparentpath = Directory.GetParent(parentpath).ToString(); //Returns the Parentfolder of your Bin/ Folder
            
Report.Info("Path", path);
Report.Info("ParentPath", parentpath);
Report.Info("GrandParentPath", grandparentpath);
The Directory Class can be found in the System.IO Namespace.

Kind regards,

Markus (S)
.
Image

Mayra
Posts: 68
Joined: Mon Dec 16, 2013 5:27 am

Re: Path to project directory

Post by Mayra » Wed Mar 05, 2014 8:27 pm

Thanks.

User avatar
maulemon
Posts: 6
Joined: Fri Oct 23, 2015 11:56 am

Re: Path to project directory

Post by maulemon » Fri Jan 15, 2016 1:11 pm

Hi,

I've tried above approach in Ranorex 5.4.4 (in a UserCode.cs) but

Code: Select all

Ranorex.Core.Testing.TestSuite.WorkingDirectory
is NULL

Could you please advise?

Thanks,
Mau.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Path to project directory

Post by Support Team » Wed Jan 27, 2016 9:25 am

Hi maulemon,

Usually, this happens when running only the module itself. In general you have to run your UserCode Module as part of a Test Suite in order to get the working directory correctly.

Regards,
Manuel
.
Image

Arunlal
Posts: 3
Joined: Wed May 25, 2016 1:32 pm

Re: Path to project directory

Post by Arunlal » Wed May 25, 2016 1:35 pm

HI ,

Even i ran my user code am not able to get the Path, its showing NULL Still.

Ranorex.Core.Testing.TestSuite.WorkingDirectory;


Could you please help us.

Regards,
Arunlal

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

Re: Path to project directory

Post by odklizec » Wed May 25, 2016 1:48 pm

Hi Arunlal,

As mentioned in Manuel's post (post before yours), you must run entire "test suite" and not just the standalone recording/code module containing this code! The method TestSuite.WorkingDirectory is TestSuite related so you must run entire test suite.
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

Arunlal
Posts: 3
Joined: Wed May 25, 2016 1:32 pm

Re: Path to project directory

Post by Arunlal » Thu May 26, 2016 12:50 pm

HI Odklizec,

Sorry, yeah i have ran my entire test suite only, but even am facing the same Error as NULL.

Did i made any mistake in this.

My scenario is, From an web application i have to click the browse button and i have to upload a document from the path where i have stored my doc.

Could you please help on this.

Regards,
Arunlal

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Path to project directory

Post by Support Team » Mon May 30, 2016 3:55 pm

Hello Arunlal,

Would you mind sending an e-mail to [email protected]. We can schedule a remote session in order to analyze the issue in more detail on your machine directly. This would be easier because we can see how exactly your test looks like.

Regards,
Bernhard
.
Image

Arunlal
Posts: 3
Joined: Wed May 25, 2016 1:32 pm

Re: Path to project directory

Post by Arunlal » Mon Jun 13, 2016 7:31 am

HI Bern,

we should not share our machine from here as its confidential.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Path to project directory

Post by Support Team » Tue Jun 14, 2016 9:48 am

Hello Arunal,

Please try the following:

Code: Select all

 var projectDirectory =   System.IO.Directory.GetParent(System.IO.Directory.GetCurrentDirectory()).Parent.FullName;
Sincerely,
Robert
.
Image