private void InitializeApplication() { var appPath = this.Automator.ActualCapabilities.App; var appArguments = this.Automator.ActualCapabilities.Arguments; var debugDoNotDeploy = this.Automator.ActualCapabilities.DebugConnectToRunningApp; var processName = this.Automator.ActualCapabilities.ProcessName; var launchDelay = this.Automator.ActualCapabilities.LaunchDelay; if (processName.Length == 0) { DriverManager.StartApp(appPath, appArguments, debugDoNotDeploy); Thread.Sleep(launchDelay); } else { if (!debugDoNotDeploy) { DriverManager.CloseDriver(); DriverManager.CloseAllApplication(processName); } try { DriverManager.StartApp(appPath, appArguments, debugDoNotDeploy); } catch { } Thread.Sleep(launchDelay); DriverManager.AttachToProcess(processName); } }