Test Studio 2017.1 / Freeze when calling custom code
1 Answer 8 Views
IT
Top achievements
Rank 1
IT asked on 30 Apr 2021, 08:33 AM

Hi,

We are using Telerik Test Studio 2017.1.207.0 and we implement custom DLL to launch or close our application.

Regularly, when calling the methods included in that code, the Test Freeze and nothing is done. I am putting the code below.

The problem concerns the call but not our code itself.

Currently the code is compiled in Debug / AnyCPU. Do you advise to compile that code in Debug or in Release mode ?

Is this problem known and is there a workaround ?

Is this problem fixed in latest version ?

Thanks in advance,

Best regards.

using System.Text;
using System.Threading.Tasks;

namespace Common
{
    public class Utility
    {
        public static void StartCustomApp(Manager manager, ExecutionContext executionContext, string customAppPath, string args = "", int waitForWindow = 10000, int waitingTime = 10000)
        {
            Assert.IsNotNull(manager, $"Manager is null.");

            manager.ActiveApplication.MainWindow.Window.Minimize();
            manager.ActiveApplication.Detach(false);
            var executablePath = executionContext.DeploymentDirectory + customAppPath;

            Assert.IsTrue(File.Exists(executablePath), $"Can not found {customAppPath} path.");

            var appName = Path.GetFileNameWithoutExtension(customAppPath);

            // Prepare the process to run
            ProcessStartInfo app = new ProcessStartInfo();
            app.Arguments = args;
            app.FileName = executablePath;        

            Assert.IsNotNull(manager.LaunchNewApplication(app), $"Failed to connect to {appName}.");

            manager.ActiveApplication.WaitForWindow($"~{appName}", waitForWindow);

            System.Threading.Thread.Sleep(waitingTime);

            manager.ActiveApplication.MainWindow.SetWindowFocus();
            manager.ActiveApplication.MainWindow.Window.Maximize();
            manager.ActiveApplication.MainWindow.RefreshVisualTrees();
        }

        public static void connectToApp(Manager manager, string appName, bool closeAppOnDetach = false)
        {
            manager.Log.WriteLine(DateTime.Now.ToString()+" - Start connectToApp"+appName);
            Assert.IsNotNull(manager, $"Manager is null.");

            Assert.IsNotNull(manager.ActiveApplication, $"ActiveApplication is null.");

            manager.Log.WriteLine(DateTime.Now.ToString() + " - detach previous App");
            manager.ActiveApplication.Detach(closeAppOnDetach);

            var proc = Process.GetProcesses().Where(p => p.ProcessName.Contains(appName)).FirstOrDefault();

            Assert.IsNotNull(proc, $"{appName} is not running.");

            manager.Log.WriteLine(DateTime.Now.ToString() + " - connect to App " + appName);
            Assert.IsNotNull(manager.ConnectToApplication(proc), $"Failed to connect to {appName}.");

            manager.ActiveApplication.MainWindow.Window.SetFocus();
            manager.ActiveApplication.MainWindow.Window.SetActive();
            manager.ActiveApplication.MainWindow.Window.Maximize();
            manager.ActiveApplication.MainWindow.RefreshVisualTrees();
        }

        public static void CloseApp(string appName)
        {
            var runningApp = System.Diagnostics.Process.GetProcesses().Where(p => p.ProcessName.Contains(appName));
            string executablePath = string.Empty;

            if (runningApp.Count() > 0)
            {
                foreach (var process in runningApp)
                    process.Kill();
            }
        }
    }
}

1 Answer, 1 is accepted

Sort by
0
Elena
Telerik team
answered on 04 May 2021, 12:18 PM

Hi Alexandre,

Thank you for your through description of the encountered issue. 

As this is your second topic today related to the specific WPF app and Test Studio version from over 4 years ago, I will not repeat myself and will proceed straight to the case.

The fact that this misbehavior appears randomly, makes me think it is related to some sort of synchronisation, or the lack of it. For example, this could be caused to some leftover processes of the application, which were not terminated when trying to start the new one. It could be also something specific for the particular app and how it manages its processes. 

However, the WPF issues are usually related to some specifics of the app itself and cannot be reproduced with any other application. Therefore we need to focus on the particular WPF app. 

Please, let me know if you had the chance to explore the latest version of Test Studio you had installed few months ago. Did you trigger the test runs using this code and did you see that freeze of test as well?

If so, we will need to collect some logging from Test Studio and most probably, have the application on our end to reproduce the misbehavior in our debugging environment. 

Please, don't get me wrong - we are ready to assist you and investigate the issues, but we need to find out, if these are present in the current version of Test Studio and if these are only reproduced with the specific application, we need to be able to debug it on our end. 

Let me know if you need any assistance on the topic with testing the WPF app with the latest version of Test Studio available, or if you have any other questions.

Thank you in advance for your cooperation.

Regards,
Elena
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Test Studio course! Check it out at https://learn.telerik.com/.
Asked by
IT
Top achievements
Rank 1
Answers by
Elena
Telerik team
Share this question
or