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(); } } } }