public static void ResetAutomationTool()
 {
     CrashHandler.HandleCrashWindows();
     Utilities.TerminateDeadLockBrowsers();
     Close(close: true, quitTool: true);
     UftApplication = null;
     Thread.Sleep(10000);
     Launch();
 }
        /// <summary>
        /// This is an Watch method to check the uft process perodically about the running status.
        /// </summary>
        public static void WatchExecution(string currentSessionFolder)
        {
            string defaultSpreadSheetPath = Path.Combine(currentSessionFolder, TestConfiguration.DefaultSpreadsheet);
            var    uftRunSessionStartTime = DateTime.Now;
            int    timeElapsed            = (DateTime.Now - uftRunSessionStartTime).Minutes;

            try
            {
                while (timeElapsed < TestConfiguration.TestRunSessionTimeout)
                {
                    CrashHandler.HandleCrashWindows();
                    timeElapsed = (DateTime.Now - uftRunSessionStartTime).Minutes;
                    if (File.Exists(defaultSpreadSheetPath))
                    {
                        break;
                    }
                    else
                    {
                        //Enable this when you are  in the need of debugging.
                        //Log.Normal("Test is running since " + timeElapsed + " minutes.");
                    }
                    Thread.Sleep(60000);
                }
            }
            catch (Exception exception)
            {
                Log.Error(exception);
            }
            finally
            {
                if (timeElapsed > TestConfiguration.TestRunSessionTimeout)
                {
                    Log.Warning("Test is running more then expected. Stopping the test now.");
                    bool isUftRunning = UnifiedFunctionalTesting.UftTest.IsRunning;
                    if (isUftRunning)
                    {
                        string beforeCloseLongRunning = Logger.CaptureScreenshot();
                        TestConfiguration.CrashListTable.Add(beforeCloseLongRunning);
                        bool isResponding = Utilities.GetRespondingState("UFT");
                        if (!isResponding)
                        {
                            CrashHandler.HandleCrashWindows();
                            Utilities.TerminateDeadLockBrowsers();
                        }
                        UnifiedFunctionalTesting.UftTest.Stop();
                        UnifiedFunctionalTesting.UftTest.Close();
                    }
                }
            }
        }