0

I'm trying to get some automated UI tests set up for a WPF application I'm working on in order to exercise the UI but I can't seem to get the app to run even using an explicit path. Because these tests need to run on any machine including our build server, it needs to be a relative path so it can run anywhere. I've looked at a few different questions, C# Application.ExecutablePath on WPF Framework 3.5 and Getting the application's directory from a WPF application for examle, and neither of those worked.

Here's an example of what my project structure looks like

Solution
 AccepatanceTestProject
  UITest.cs
 MainApp
  MainApp
  Bin
   Debug
    MainApp.Exe

I'm trying to access the MainApp.exe in MainApp\Bin\Debug\MainApp.exe from AcceptanceTestProject\UITest.cs

System.Reflection.Assembly.GetEntryAssembly().Location seems to be the most suggested option, but this returns the path to the UITest.cs executable directory. Any advice would be greatly appreciated. Thanks!

Community
  • 1
  • 1
CGideon
  • 143
  • 2
  • 15
  • Have you referred to the [Samples](https://github.com/TestStack/White/tree/master/src/Samples)? – Joshua Shearer Jan 21 '16 at 15:02
  • @JoshuaShearer Yep, following their example of using Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).AbsolutePath); Returns: "C:\\source\\repo\\project\\UI.Tests\\bin\\Debug" – CGideon Jan 21 '16 at 15:17

1 Answers1

0

In case your MainApp.exe and your test are always in the same solution, you can use the path below to access the MainApp.exe.

string path = @"..\..\..\MainApp\Bin\Debug\MainApp.exe";
Buaban
  • 5,029
  • 1
  • 17
  • 33