New to Telerik Test Studio Dev EditionStart a free 30-day trial

Connect to a Running WPF Application

I would like to connect to an already running WPF application and execute the test there, instead of launching a new instance of the app.

Solution

When you Quick Execute or execute a Test List, a new instance of the app launches from its pre-configured location.

To work around this limitation, create a mock application to feed to Test Studio. Then insert a coded step as the first step of the test. Use the following code which closes the mock application and connects to the desired application if it's running. If not, a new instance is launched.

C#
    ActiveApplication.Quit();
    var runningApp = System.Diagnostics.Process.GetProcesses().Where(p => p.ProcessName == "WPFHelloWorld");
    
    if (runningApp.Count() != 0)
    {
        Manager.ConnectToApplication(runningApp.FirstOrDefault());
    }
    else
    {
        Manager.LaunchNewApplication(@"C:\ApplicationFolder\WPFHelloWorld.exe");
    }
    
    Manager.ActiveApplication.MainWindow.RefreshVisualTrees();
In this article
Solution
Not finding the help you need?
Contact Support