Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 922
Muhammad Omar Farooq Avatar asked Sep 05 '14 01:09

Muhammad Omar Farooq


2 Answers

you could do:

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

happy coding

like image 175
Alas Avatar answered Sep 26 '22 07:09

Alas


Or easier

Application application = Application.AttachOrLaunch(@"someapplication.exe");
like image 33
Rik Avatar answered Sep 24 '22 07:09

Rik