How do whites work on an already running application?

I use the testStack / White library to automate the application. Currently it works fine, but it throws an exception if the application is already running. Is there a way to put a check, for example, if the application is already running, and then not call it. i mean, then we can skip this line of code

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

I could not find good documentation about White. Any help would be appreciated.

+5
source share
3 answers

You can do:

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

happy coding

+9
source

Or easier

 Application application = Application.AttachOrLaunch(@"someapplication.exe"); 
+2
source

To return to the previous answer, find the name of the application you want ...

1) Open the task manager, 2) find the process you want to use with white 3) right-click the process you want and select properties 4) The name you are using is in the text box. Usually does not have .exe.

+1
source

Source: https://habr.com/ru/post/1201861/


All Articles