Page 1 of 1

Path to project directory

Posted: Mon Mar 03, 2014 11:41 pm
by Mayra
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

Re: Path to project directory

Posted: Wed Mar 05, 2014 10:28 am
by Support Team
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)

Re: Path to project directory

Posted: Wed Mar 05, 2014 8:27 pm
by Mayra
Thanks.

Re: Path to project directory

Posted: Fri Jan 15, 2016 1:11 pm
by maulemon
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.

Re: Path to project directory

Posted: Wed Jan 27, 2016 9:25 am
by Support Team
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

Re: Path to project directory

Posted: Wed May 25, 2016 1:35 pm
by Arunlal
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

Re: Path to project directory

Posted: Wed May 25, 2016 1:48 pm
by odklizec
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.

Re: Path to project directory

Posted: Thu May 26, 2016 12:50 pm
by Arunlal
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

Re: Path to project directory

Posted: Mon May 30, 2016 3:55 pm
by Support Team
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

Re: Path to project directory

Posted: Mon Jun 13, 2016 7:31 am
by Arunlal
HI Bern,

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

Re: Path to project directory

Posted: Tue Jun 14, 2016 9:48 am
by Support Team
Hello Arunal,

Please try the following:

Code: Select all

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