public HttpStatusCode StartMonitorCrash() { UtilCmd.Clear(); UtilCmd.WriteLine("Crash Monitor is running!"); //UtilCmd.WriteLine("*********************************************"); UtilProcess.StartProcess(_portal.SwLnkPath); UtilTime.WaitTime(1); MonitorCrashThread = new Thread(() => { while (true) { if (UtilProcess.IsProcessExistedByName(_portal.SwProcessName)) { UtilTime.WaitTime(0.5); } else { UtilCmd.WriteLine("Crash occurred!"); var t = RequestApi.Get("http://10.10.51.59:9100/Crashed"); AbortMonitorCrash(); return; } } }); MonitorCrashThread.Start(); return(HttpStatusCode.OK); }
public void LaunchAndCheckCrash(long testTimes) { var crashTimes = 0; UtilCmd.Clear(); for (var i = 1; i < testTimes; i++) { var titleTotal = $"Reopen Times: {i} - Crash Times: {crashTimes}"; var logLines = UtilFile.ReadFileByLine(LogPathLaunch); logLines.ForEach(UtilCmd.WriteLine); //logLines.ForEach(line => UtilCmd.WriteLine(line)); var launchLogTime = GetRestartLogTime(); var screenshotPath = Path.Combine(ScreenshotsPath, crashTimes.ToString()); UtilProcess.StartProcess(SwLnkPath); Timeout = 1; UtilCmd.WriteTitle($"{titleTotal} - Searching MP+ UI."); var startTime = DateTime.Now; var dialogWarning = UtilWait.ForAnyResultCatch(() => { UtilCmd.WriteTitle($"{titleTotal} - Searching Warning dialog of the MP+ in 60s. Time elapsed: {(DateTime.Now - startTime).Seconds}s."); SwMainWindow = new AT().GetElement(MPObj.MainWindow, Timeout); // The MP+ will change after a while. return(SwMainWindow.GetElement(MPObj.DialogWarning, Timeout)); }, 60, 2); if (SwMainWindow == null) { UtilCapturer.Capture(i.ToString()); UtilFile.WriteFile(LogPathLaunch, $"{launchLogTime}: Reopen Times: {i} - Could not open MasterPlus."); crashTimes++; } UtilTime.WaitTime(1); UtilProcess.KillProcessByName(SwProcessName); UtilTime.WaitTime(1); } }
public void Capture(string commentOnWeb = "Step_End", string imageName = "", string capturesRelativePath = "", UtilCapturer.ImageType imageType = UtilCapturer.ImageType.PNG) { try { if (imageName.Equals("")) { imageName = UtilTime.GetLongTimeString(); } if (capturesRelativePath.Equals("")) { capturesRelativePath = this.GetCaptureRelativePath(); } var t = Path.Combine(capturesRelativePath, imageName); var manualCheckLink = SetNeedToCheck(commentOnWeb, Path.Combine(capturesRelativePath.Split('\\').Last(), imageName + "." + imageType)); manualCheckLink = SetAsLink(manualCheckLink); UtilCapturer.Capture(t, imageType); UtilTime.WaitTime(0.5); if (CurrentTestCase != null) { CurrentTestCase.NodeNeedToCheck += manualCheckLink; } } catch (Exception e) { throw new Exception("Capture image failed." + e.Message); } }
private void _ScrollMenuItemSubItem(AT reassignDropdown) { try { var left = (int)reassignDropdown.GetElementInfo().RectangleLeft() + 10; var top = (int)reassignDropdown.GetElementInfo().RectangleTop() + 50; switch (_scrollNum) { case 0: HWSimulator.HWSend.MoveCursorAndDo(left, top, HWSimulator.HWSend.MouseKeys.WHEELDOWN); UtilTime.WaitTime(1); HWSimulator.HWSend.MoveCursorAndDo(left, top, HWSimulator.HWSend.MouseKeys.WHEELDOWN); UtilTime.WaitTime(1); HWSimulator.HWSend.MoveCursorAndDo(left, top, HWSimulator.HWSend.MouseKeys.WHEELDOWN); UtilTime.WaitTime(1); _scrollNum = 1; break; case 1: HWSimulator.HWSend.MoveCursorAndDo(left, top, HWSimulator.HWSend.MouseKeys.WHEELUP); UtilTime.WaitTime(1); HWSimulator.HWSend.MoveCursorAndDo(left, top, HWSimulator.HWSend.MouseKeys.WHEELUP); UtilTime.WaitTime(1); HWSimulator.HWSend.MoveCursorAndDo(left, top, HWSimulator.HWSend.MouseKeys.WHEELUP); UtilTime.WaitTime(1); _scrollNum = 0; break; } } catch (Exception e) { throw new Exception("Failed to _ScrollMenuItemSubItem. " + e.Message); } }
private void WaitForLoadingOrReconnecting(AT profileTmp, AT loadingTmp) { if (UtilOs.GetOsVersion().Contains(UtilOs.Name.Win10)) { UtilTime.WaitTime(3); } else { UtilTime.WaitTime(3); } try { profileTmp = SwMainWindow.GetElement(aTElementStruct: PortalObj.Profile_1, treeScope: ATElement.TreeScope.Descendants, returnNullWhenException: true); if (profileTmp == null) { SwMainWindow.GetElement(aTElementStruct: PortalObj.TabItem_PROFILES, treeScope: ATElement.TreeScope.Descendants).DoClickPoint(); return; } do { loadingTmp = SwMainWindow.GetElement(aTElementStruct: PortalObj.Lable_LOADING, treeScope: ATElement.TreeScope.Descendants, returnNullWhenException: true); } while (loadingTmp != null); } catch (Exception) { // ignored } }
public TestIt() { _MpCases = new MasterPlusTestCases(); KeysSpy = new KeysSpyOp(_MpCases.MpActions.KeySpyRelativePath); _portalTestFlows = new PortalTestFlows(); //AssembleTopMenu(); GetKeyboardKeysFromKeyMapTabFile(); GetMatrixFromFile(); UtilKeys.SetPhysicalKeyStatus(KbKeys.SC_KEY_NUM_LOCK.KeyValue, UtilKeys.Status.On); UtilKeys.SetPhysicalKeyStatus(KbKeys.SC_KEY_CAP.KeyValue, UtilKeys.Status.Off); //UtilLoop.testA(); //_MpCases.Case_AssignInLoop(blAssignKey: true, blVerifyKeyWork: false, blScanCodeInput: true); _MpCases.Case_AssignInLoop(true, false, true); this.Suit_KeyMappingBaseTest("SK652"); UtilProcess.KillAllProcessesByName("wmplayer"); UtilTime.WaitTime(1); var p = UtilWmp.StartWmpWithMedias(Path.Combine(_MpCases.MpActions.MediaFolderPath, "1.mp3"), Path.Combine(_MpCases.MpActions.MediaFolderPath, "2.mp3"), Path.Combine(_MpCases.MpActions.MediaFolderPath, "3.mp3")); var wmpWindow = new AT().GetElementFromHwndAndWaitAppears(p); var sliderbar = wmpWindow.GetElementFromDescendants(new ATElementStruct() { ControlType = AT.ControlType.Slider }); var barValue1 = sliderbar.DoGetValue(); UtilTime.WaitTime(0.5); var barValue2 = sliderbar.DoGetValue(); _MpCases.Case_CheckAllKeysOnRelayController(); }
public void Flow_Installation(string buildPath, bool checkRemove = true, string language = "English") { UtilProcess.KillProcessByFuzzyName("MasterPlus"); UtilTime.WaitTime(1); var uninstallerPath = UtilRegistry.GetProductInfo("MasterPlus(PER. Only).*", UtilRegistry.ProductInfo.UninstallString); if (!uninstallerPath.Equals(string.Empty)) { WriteConsoleTitle(LaunchTimes, $"Waiting for silent uninstalling. ({2}s)", 2); UtilProcess.StartProcessGetString(uninstallerPath, "/silent"); UtilTime.WaitTime(1); } UtilProcess.StartProcess(buildPath); AT Window_SelectLauguage = new AT().GetElement(PortalObj.Window_SelectLauguage, Timeout = 5, treeScope: AT.TreeScope.Children); AT ComboBox_SelectLauguage = Window_SelectLauguage.GetElement(PortalObj.ComboBox_SelectLauguage); ComboBox_SelectLauguage.DoExpand(); Window_SelectLauguage = new AT().GetElement(PortalObj.Window_SelectLauguage, Timeout = 5, treeScope: AT.TreeScope.Children); //refresh Window_SelectLauguage.GetElement(name: language, treeScope: AT.TreeScope.Descendants).DoSelect(1); AT Button_OK = Window_SelectLauguage.GetElement(PortalObj.Button_Install_OK, Timeout = 2); Button_OK.DoClick(1); AT Window_InstallWizard = new AT().GetElement(PortalObj.Window_InstallWizard, Timeout = 5, treeScope: AT.TreeScope.Children); UtilTime.WaitTime(1); AT Button_RemoveCache = Window_InstallWizard.GetElement(PortalObj.CheckBox_RemoveCache, Timeout = 2); Button_RemoveCache.DoClickPoint(waitTime: 1); AT Button_Next = Window_InstallWizard.GetElement(PortalObj.Button_Next); Button_Next.DoClick(1); AT Button_Location_Next = Window_InstallWizard.GetElement(PortalObj.Button_Location_Next); Button_Location_Next.DoClick(2); try { AT Dialog_FolderExists = Window_InstallWizard.GetElement(PortalObj.Dialog_FolderExists); AT Button_DialogFolderExists_Yes = Dialog_FolderExists.GetElement(PortalObj.Button_DialogFolderExists_Yes); Button_DialogFolderExists_Yes.DoClick(1); } catch (Exception) { } AT Button_SelectStartMemuFolder_Next = Window_InstallWizard.GetElement(PortalObj.Button_SelectStartMemuFolder_Next); Button_SelectStartMemuFolder_Next.DoClick(1); AT Button_AddtionalTask_Next = Window_InstallWizard.GetElement(PortalObj.Button_AddtionalTask_Next); Button_AddtionalTask_Next.DoClick(1); AT Button_ReadyToInstall_Install = Window_InstallWizard.GetElement(PortalObj.Button_ReadyToInstall_Install); Button_ReadyToInstall_Install.DoClick(1); AT CheckBox_LaunchPortal = Window_InstallWizard.GetElement(PortalObj.CheckBox_LaunchPortal, Timeout = 20); AT Button_Finish = Window_InstallWizard.GetElement(PortalObj.Button_Finish); Button_Finish.DoClick(1); AT Window_MasterPlusPer = new AT().GetElement(PortalObj.Window_MasterPlusPer, timeout: 10); }
public void OpenVirtualBox() { _TestStepHandler.Exec(() => { UtilTime.WaitTime(1); UtilProcess.StartProcess(@"D:\Program Files\Oracle\VirtualBox\VirtualBox.exe"); _TestStepHandler.Capture(""); } ); }
private AT LaunchAndGetWmplayer() { UtilProcess.KillAllProcessesByName("wmplayer"); UtilTime.WaitTime(1); var p = UtilWmp.StartWmpWithMedias(Path.Combine(this.MediaFolderPath, "1.mp3"), Path.Combine(this.MediaFolderPath, "2.mp3"), Path.Combine(this.MediaFolderPath, "3.mp3")); var wmpWindow = new AT().GetElementFromHwndAndWaitAppears(p); HWSimulator.HWSend.MoveMouseTo((int)(wmpWindow.GetElementInfo().RectangleRight() - wmpWindow.GetElementInfo().RectangleLeft()) / 2, (int)(wmpWindow.GetElementInfo().RectangleBottom() - wmpWindow.GetElementInfo().RectangleTop()) / 2); return(wmpWindow); }
private static void WriteConsoleTitlePri(string title, int timeout = 0) { Console.Title = title; var t = Console.Title; if (timeout != 0) { UtilTime.CountDown(timeout, s => { Console.Title = t + " > " + s; }); } UtilTime.WaitTime(timeout); }
public void Load() { if (app == null) { UtilProcess.KillProcessByName(System.IO.Path.GetFileName(_appPath)); UtilTime.WaitTime(1); var p = UtilProcess.StartProcessReturn(_appPath); UtilWait.ForTrue(() => p.MainWindowHandle != IntPtr.Zero, 3); app = new AT().GetElementFromHwnd(p.MainWindowHandle); } }
public void Exec(Action action, string nodeDescription, string nodeExpectedResult, string nodeErrorMessage, WhenCaseFailed blockOrRun) { var elapsedTime = 0; var r = new Reporter.ResultTestCase() { NodeDescription = nodeDescription, NodeExpectedResult = nodeExpectedResult, }; CurrentTestCase = r; if (Reporter.BlockAllLeftCasesAnyway) { r.NodeResult = Reporter.Result.BLOCK; } else if (BlockCurrentCase && blockOrRun != WhenCaseFailed.StillRunThisCase) { r.NodeResult = Reporter.Result.BLOCK; if (BlockCurrentCase && blockOrRun == WhenCaseFailed.BlockAllLeftCases) { Reporter.BlockAllLeftCasesAnyway = true; } } else { try { //var actualResult = action.Invoke(); var currentTime = DateTime.Now; action.Invoke(); elapsedTime = UtilTime.TimeElapsed(currentTime).Seconds; if (r.AttrMessage != null || r.ErrorMessages.Any()) { r.NodeResult = Reporter.Result.FAIL; } } catch (Exception e) { if (blockOrRun == WhenCaseFailed.BlockAllLeftCases) { Reporter.BlockAllLeftCasesAnyway = true; } Reporter.BlockCurrentCase = true; r.NodeResult = Reporter.Result.FAIL; //r.AttrMessage = nodeErrorMessage += $" [{e.Message}]"; r.ErrorMessages.Add(CurrentTestCase.AttrMessage ?? e.Message); } Capture(); } r.AttrTime = elapsedTime; r.AttrMessage = this.SetAsLines(r.ErrorMessages.ToArray()); AddTestStep(r, GetResultTestInfo()); }
private void OpenRemovableDevices(AT windowVm) { var tabTestVm = windowVm.GetElement(VmObj.Tab_TestVM); tabTestVm.DoSetFocus(); UtilTime.WaitTime(1); tabTestVm.DoClickPoint(10, 10, mk: HWSimulator.HWSend.MouseKeys.RIGHT); UtilTime.WaitTime(0.5); var itemRemovableDevices = new AT().GetElement(VmObj.Item_RemovableDevices); itemRemovableDevices.DoClickPoint(mk: HWSimulator.HWSend.MouseKeys.NOTCLICK); UtilTime.WaitTime(0.5); }
/// <summary> /// /// </summary> public static void CloseIE() { for (int i = 0; i < 3; i++) { try { AT IE = new AT().GetElement(ClassName: AT.ClassName.IEFrame); IE.DoWindowEvents().Close(); } catch (Exception) { } UtilTime.WaitTime(1); } }
private void PlugOutOrIn() { AT itemCon; UtilTime.WaitTime(1); try { itemCon = new AT().GetElement(VmObj.Item_Connect); } catch (Exception) { itemCon = new AT().GetElement(VmObj.Item_Disconnect); } itemCon.DoClickPoint(10, 10); }
public void PowerOff(int waitSecond = 10) { try { if (IsVmRunning(vmxFullPath)) { string strlist = UtilProcess.StartProcessGetString(VmCmdControl.vmrunInstallFullPath, string.Format("-T ws stop \"{0}\"", this.vmxFullPath)); UtilTime.WaitTime(waitSecond); } } catch (Exception ex) { Logger.LogThrowMessage(string.Format("Failed to power off VM [{0}]", this.vmxFullPath), new StackFrame(0).GetMethod().Name, ex.Message); } }
private void WaitForLoading(AT loadingTmp) { UtilTime.WaitTime(2); try { while (true) { loadingTmp = SwMainWindow.GetElement(aTElementStruct: PortalObj.Lable_LOADING, treeScope: ATElement.TreeScope.Descendants); } } catch (Exception) { // ignored } }
protected void HandleWrongStepResult(string comment, long num = 0) { if (comment == "") { return; } //string tmp = $"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}: {Result.FAIL} - Num > [{num}]. Error > [{comment}]"; var tmp = $"{DateTime.Now:yyyy-MM-dd HH:mm:ss}: {Reporter.Result.FAIL}. Error > [{comment}]"; UtilCapturer.Capture(Path.Combine(ScreenshotsPath, num.ToString())); UtilFile.WriteFile(Path.Combine(LogPathLaunch), tmp); Console.WriteLine(tmp); //UtilProcess.KillProcessByName(this.SwProcessName); UtilTime.WaitTime(2); }
public void RestartSystemAndCheckDeviceRecognitionFlow(XmlOps xmlOps) { UtilFolder.CreateDirectory(Path.Combine(ScreenshotsPath, "Restart")); var restartLogTime = GetRestartLogTime(); var screenshotPath = Path.Combine(RestartScreenshotPath, restartLogTime); var logLines = UtilFile.ReadFileByLine(LogPathRestart); logLines.ForEach(line => UtilCmd.WriteLine(line)); var titleLaunchTimes = xmlOps.GetRestartTimes(); var titleTotal = $"Restart Times: {titleLaunchTimes} - Error Times: {logLines.Count}"; var t = UtilWait.WaitTimeElapseThread($"{titleTotal} - Waiting 35s.", 35); t.Start(); t.Join(); if (!File.Exists(SwLnkPath)) { UtilCmd.WriteTitle($"{titleTotal} - Could not find {SwLnkPath}."); UtilCmd.PressAnyContinue(); } UtilProcess.StartProcess(SwLnkPath); Timeout = 1; UtilCmd.WriteTitle($"{titleTotal} - Searching MP+ UI."); var startTime = DateTime.Now; var dialogWarning = UtilWait.ForAnyResultCatch(() => { UtilCmd.WriteTitle($"{titleTotal} - Searching Warning dialog of the MP+ in 60s. Time elapsed: {(DateTime.Now - startTime).Seconds}s."); SwMainWindow = new AT().GetElement(MPObj.MainWindow, Timeout); // The MP+ will change after a while. return(SwMainWindow.GetElement(MPObj.DialogWarning, Timeout)); }, 60, 3); if (SwMainWindow == null) { //UtilCmd.WriteTitle($"Restart Times: {titleLaunchTimes} - Could not open MasterPlus."); UtilCapturer.Capture(screenshotPath); UtilFile.WriteFile(LogPathRestart, $"{restartLogTime}: Restart Times: {titleLaunchTimes} - Could not open MasterPlus."); } else if (dialogWarning != null) { UtilCapturer.Capture(screenshotPath); //UtilCmd.WriteTitle($"Restart Times: {titleLaunchTimes} - The device was not displayed"); UtilFile.WriteFile(LogPathRestart, $"{restartLogTime}: Restart Times: {titleLaunchTimes} - The device was not displayed."); } xmlOps.SetRestartTimes(Convert.ToInt16(titleLaunchTimes) + 1); UtilTime.WaitTime(1); UtilProcess.KillProcessByName(this.SwProcessName); //UtilProcess.ExecuteCmd();// sometimes it does not work somehow. UtilOS.Reboot(); }
public void SendToPort(string key, double DisconnectingTime = 0.2, double executedWait = 0) { if (_workablePortName.Equals("")) { Load(); } var key1 = Convert.ToInt16(key.Split(',')[0].Trim()); var key2 = Convert.ToInt16(key.Split(',')[1].Trim()); OpenDo(key1); OpenDo(key2); UtilTime.WaitTime(DisconnectingTime); CloseDo(key2); CloseDo(key1); UtilTime.WaitTime(executedWait); }
public void PowerOn(int waitSecond = 10) { try { string result = UtilProcess.StartProcessGetString(VmCmdControl.vmrunInstallFullPath, string.Format("-T ws start \"{0}\"", this.vmxFullPath)); if (!result.Equals("")) { throw new Exception(result); } UtilTime.WaitTime(waitSecond); } catch (Exception ex) { Logger.LogThrowMessage(string.Format("Failed to power on VM [{0}].", this.vmxFullPath), new StackFrame(0).GetMethod().Name, ex.Message); } }
public void ProfilesImExAimpadSwitch(long testTimes) { var TabItem_Profiles = SwMainWindow.GetElement(PortalObj.TabItem_PROFILES); TabItem_Profiles.DoClickPoint(); UtilTime.WaitTime(2); for (var i = 1; i < testTimes; i++) { WriteConsoleTitle(i, $"Starting to Import Export switch (Support Aimpad Mode). ({Timeout}s)", Timeout); ProfilesImExSwitch(PortalObj.Profile_2, null, null, "EXPORT", true); ProfilesImExSwitch(PortalObj.Profile_1, null, null, "IMPORT", true); ProfilesImExSwitch(PortalObj.Profile_1, null, null, "", true); ProfilesImExSwitch(PortalObj.Profile_2, null, null, "", true); ProfilesImExSwitch(PortalObj.Profile_3, null, null, "", true); ProfilesImExSwitch(PortalObj.Profile_4, null, null, "", true); } }
public void ProfilesImExSwitch(long testTimes) { var tabItemProfiles = SwMainWindow.GetElement(PortalObj.TabItem_PROFILES); tabItemProfiles.DoClickPoint();//"DoClick();" does not work UtilTime.WaitTime(2); for (var i = 1; i < testTimes; i++) { WriteConsoleTitle(i, $"Starting to Import Export switch. ({Timeout}s)", Timeout); ProfilesImExSwitch(PortalObj.Profile_2, null, null, "EXPORT"); ProfilesImExSwitch(PortalObj.Profile_1, null, null, "IMPORT"); ProfilesImExSwitch(PortalObj.Profile_1, null, null, ""); ProfilesImExSwitch(PortalObj.Profile_2, null, null, ""); ProfilesImExSwitch(PortalObj.Profile_3, null, null, ""); ProfilesImExSwitch(PortalObj.Profile_4, null, null, ""); } }
public void PowerOn(int waitSecond = 10) { try { var result = UtilProcess.StartProcessGetString(VmrunInstallFullPath, $"-T ws start \"{_vmxFullPath}\""); if (!result.Equals("")) { throw new Exception(result); } UtilTime.WaitTime(waitSecond); } catch (Exception ex) { Logger.LogThrowMessage($"Failed to power on VM [{_vmxFullPath}].", new StackFrame(0).GetMethod().Name, ex.Message); } }
public void IsSwCrash(int checkTime = 0, int checkInternal = 0) { if (checkInternal > 0) { UtilTime.WaitTime(checkInternal); WriteConsoleTitle(LaunchTimes, $"Wait ({checkInternal}s)", checkInternal); } WriteConsoleTitle(LaunchTimes, $"Waiting for checking crash. ({checkTime}s)", checkTime); var crashWindow = new AT().GetElement(name: Obj.NameCrashMainWindow, timeout: checkTime, returnNullWhenException: true); if (crashWindow == null) { return; } HandleWrongStepResult(Msg.Crash, LaunchTimes); throw new Exception(Msg.Crash); }
public void PowerOff(int waitSecond = 10) { try { if (!IsVmRunning(_vmxFullPath)) { return; } UtilProcess.StartProcessGetString(VmrunInstallFullPath, $"-T ws stop \"{_vmxFullPath}\""); UtilTime.WaitTime(waitSecond); } catch (Exception ex) { Logger.LogThrowMessage($"Failed to power off VM [{_vmxFullPath}]", new StackFrame(0).GetMethod().Name, ex.Message); } }
/// <summary> /// /// </summary> /// <typeparam name="T"></typeparam> /// <param name="sender"></param> /// <param name="timeout"></param> /// <param name="waitEvent"></param> /// <param name="interval"></param> /// <param name="dateInterval"></param> /// <returns></returns> public static AT GetElementAndWaitProcess <T>(T sender, string timeout, string waitEvent = WaitEvent.Existed, string interval = "0.5", UtilTime.DateInterval dateInterval = UtilTime.DateInterval.Second) { try { DateTime dt = DateTime.Now; AT at = null; while (true) { UtilTime.WaitTime(Convert.ToDouble(interval)); try { at = WaitProcessEventDelegate(sender, new WaitProcessArgs()); if (at != null && waitEvent.Equals(WaitEvent.Existed)) { UtilTime.WaitTime(Convert.ToDouble(interval)); return(at); } else if (at == null && waitEvent.Equals(WaitEvent.Disappeared)) { return(null); } } catch (Exception) { throw; } if (UtilTime.DateDiff(dt, DateTime.Now, dateInterval) > Convert.ToDouble(timeout)) { throw new Exception(string.Format("Timeout > {0}s.", timeout)); } } } catch (Exception) { throw; } finally { foreach (Delegate item in WaitProcessEventDelegate.GetInvocationList()) { typeof(AT).GetEvent(nameof(WaitProcessEventDelegate)).RemoveEventHandler(new AT(), item); //typeof(AT).GetEvent("WaitProcessEventDelegate").RemoveEventHandler(new AT(), item); } } }
public AT LaunchMasterPlus(string appFullPath, int timeout, bool killCurrentOne = true) { if (killCurrentOne) { UtilProcess.KillProcessByName(SwProcessName); UtilTime.WaitTime(1); } if (appFullPath.Equals("")) { appFullPath = SwLnkPath; } if (!UtilFile.Exists(appFullPath)) { throw new Exception($"{appFullPath} does not exist."); } UtilProcess.StartProcess(appFullPath); return(GetMasterPlusMainWindowForLaunching(timeout)); }
public void LaunchSw() { try { UtilProcess.StartProcess(SwLnkPath); UtilTime.WaitTime(2); Timeout = 20; WriteConsoleTitle(LaunchTimes, $"Waiting for launching. ({Timeout}s)", Timeout); SwMainWindow = new AT().GetElement(name: Obj.NameMainWidow, className: Obj.ClassNameMainWindow, timeout: Timeout); //Qt5QWindowIcon UtilTime.WaitTime(2); } catch (Exception) { //SwMainWindow = new AT().GetElement(Name: Obj.NameMainWidow, ClassName: Obj.ClassNameMainWindow, Timeout: Timeout); HandleWrongStepResult("Cannot find the App.", LaunchTimes); Console.ReadKey(); } }
public void CloseSw() { var buttonClose = SwMainWindow.GetElement(name: Obj.ButtonCloseMainWindow, controlType: ATElement.ControlType.Button, treeScope: ATElement.TreeScope.Descendants); buttonClose.DoClick(); Timeout = 2; WriteConsoleTitle(LaunchTimes, $"Waiting for closing1. ({Timeout}s)", Timeout); UtilTime.WaitTime(Timeout); try { WriteConsoleTitle(LaunchTimes, $"Waiting for closing2. ({Timeout}s)", Timeout); buttonClose = SwMainWindow.GetElement(name: Obj.ButtonCloseMainWindow, controlType: ATElement.ControlType.Button, treeScope: ATElement.TreeScope.Descendants); //button_Close.DoClickWithNewThread(); buttonClose.DoClickPoint();//Don't know why sometimes "button_Close.DoClick();" does not work UtilTime.WaitTime(Timeout); } catch (Exception) { // ignored } }