Muhammad Omar Farooq Muhammad Omar Farooq - 1 year ago 84
C# Question

How do White work on already running application?

I am using testStack/White library to automate an application. Right now its working fine but it throws exception if the application is already running. Is there any way to put a check e.g if application is already running then do not invoke it. i mean, then we can skip this line of code

Application application = Application.Launch(@"someapplication.exe");

I could not find any good documentation of White.
Any help will be appreciated.

Answer Source

you could do:

Application application;
Process[] processes = Process.GetProcessesByName(@"someapplication.exe");
if (processes.Length == 0)
  application = Application.Launch(@"someapplication.exe");
  application = Application.Attach(@"someapplication.exe");

happy coding