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 CloseMasterPlus(int timeout = 10) { var buttonClose = GetMasterPlusMainWindow().GetElementFromChild(MPObj.CloseMasterPlusButton); buttonClose.DoClickPoint(1); UtilWait.ForTrue(() => !UtilProcess.IsProcessExistedByName(this.SwProcessName), timeout); }
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 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 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); }
private dynamic SuitCommon(Func <dynamic> Suit_Func, string deviceName) { _MpCases.Ireporter.GetResultTestInfo().AttrDeviceModel = deviceName; _MpCases.Ireporter.GetResultTestInfo().AttrTestName = Suit_Func.Method.Name; var r = Suit_Func.Invoke(); _MpCases.LaunchTestReport(); UtilProcess.KillAllProcessesByName("KeysSpy"); return(r); }
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); }
public void OpenVirtualBox() { _TestStepHandler.Exec(() => { UtilTime.WaitTime(1); UtilProcess.StartProcess(@"D:\Program Files\Oracle\VirtualBox\VirtualBox.exe"); _TestStepHandler.Capture(""); } ); }
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 ExtractZip(string source, string destination) { //Shell(constPath7zEXE & " x """ & pathBuildZIP & "\" & fullBuildName & ".zip"" - y - o""" & pathATScript & "\" & strWhichVM & "\" & """") try { UtilProcess.StartProcessGetInt(Tool7Z, $"x \"{source}\" -y -o\"{destination}\""); } catch (Exception ex) { Logger.LogThrowMessage($"Failed to extract zip [{source}] to [{destination}].", new StackFrame(0).GetMethod().Name, ex.Message); } }
public AT GetMasterPlusMainWindowForLaunching(int timeout = 0) { return(UtilWait.ForNonNull(() => { if (UtilProcess.IsProcessExistedByName("RENEW")) { UtilProcess.KillProcessByName("RENEW"); } var mainWindow = GetMasterPlusMainWindow(); mainWindow.GetElement(MPObj.DeviceList); return mainWindow; }, timeout, 2)); }
public bool IsVmRunning(string vmxFullPath) { try { var runningVMs = UtilProcess.StartProcessGetStrings(VmrunInstallFullPath, "list"); return(runningVMs.Any(vm => vm.Equals(vmxFullPath))); } catch (Exception ex) { Logger.LogError($"Failed to get if {vmxFullPath} was running.", new StackFrame(0).GetMethod().Name, ex.Message); return(false); } }
public void DeleteShareConnect(string ipOrName, string folderName = "") { string para = string.Format(@"use /delete {0}", this.ShareFolderFullPath); try { UtilProcess.StartProcessGetString("net", para); } catch (Exception) { //Logger.LogThrowMessage(string.Format(@"Failed to execute [net {0}]", para), new StackFrame(0).GetMethod().Name, ex.Message); throw new Exception(string.Format(@"Failed to execute [net {0}]", para)); } }
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); } }
public void RevertToSnapshot(string revertSnapshotName) { try { string result = UtilProcess.StartProcessGetString(VmCmdControl.vmrunInstallFullPath, string.Format("revertToSnapshot \"{0}\" \"{1}\"", this.vmxFullPath, revertSnapshotName)); if (!result.Equals("")) { throw new Exception(result); } } catch (Exception ex) { Logger.LogThrowMessage(string.Format("Failed to revert Snapshot [{0}] of VM [{1}].", revertSnapshotName, this.vmxFullPath), new StackFrame(0).GetMethod().Name, ex.Message); } }
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 RevertToSnapshot(string revertSnapshotName) { try { var result = UtilProcess.StartProcessGetString(VmrunInstallFullPath, $"revertToSnapshot \"{_vmxFullPath}\" \"{revertSnapshotName}\""); if (!result.Equals("")) { throw new Exception(result); } } catch (Exception ex) { Logger.LogThrowMessage($"Failed to revert Snapshot [{revertSnapshotName}] of VM [{_vmxFullPath}].", new StackFrame(0).GetMethod().Name, ex.Message); } }
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 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); } }
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 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 TakeSnapshot(string takeSnapshotName) { try { if (takeSnapshotName.Trim().Equals("")) { throw new Exception("Snapshot was invalid."); } string result = UtilProcess.StartProcessGetString(VmCmdControl.vmrunInstallFullPath, string.Format("snapshot \"{0}\" \"{1}\"", this.vmxFullPath, takeSnapshotName)); if (!result.Equals("")) { throw new Exception(result); } } catch (Exception ex) { Logger.LogThrowMessage(string.Format("Failed to take Snapshot [{0}] of VM [{1}].", takeSnapshotName, this.vmxFullPath), new StackFrame(0).GetMethod().Name, ex.Message); } }
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 bool IsSnapshotExisting(string snapshotName) { try { string[] snapshots = UtilProcess.StartProcessGetStrings(VmCmdControl.vmrunInstallFullPath, string.Format("listSnapshots \"{0}\"", vmxFullPath)); foreach (string snapshot in snapshots) { if (snapshot.Equals(snapshotName)) { return(true); } } return(false); } catch (Exception ex) { Logger.LogThrowMessage(string.Format("Failed to find Snapshot [{0}] from VM [{1}].", vmxFullPath, snapshotName), new StackFrame(0).GetMethod().Name, ex.Message); return(false); } }
public void ConnectShare(bool isPersistent = true) { string persistentValue = "YES"; if (!isPersistent) { persistentValue = "NO"; } string para = string.Format(@"use {0} {1} {2} /PERSISTENT:{3}", this.ShareFolderFullPath, UserName.Equals("") ? "" : "/User:"******"net", para); } catch (Exception) { //Logger.LogThrowMessage(string.Format(@"Failed to execute [net {0}]", para), new StackFrame(0).GetMethod().Name, ex.Message); throw new Exception(string.Format(@"Failed to execute [net {0}]", para)); } }
public bool IsVmRunning(string vmxFullPath) { try { string[] runningVMs = UtilProcess.StartProcessGetStrings(VmCmdControl.vmrunInstallFullPath, "list"); foreach (string vm in runningVMs) { if (vm.Equals(vmxFullPath)) { return(true); } } return(false); } catch (Exception ex) { Logger.LogError(string.Format("Failed to get if {0} was running.", vmxFullPath), new StackFrame(0).GetMethod().Name, ex.Message); return(true); } }
public void TakeSnapshot(string takeSnapshotName) { try { if (takeSnapshotName.Trim().Equals("")) { throw new Exception("Snapshot was invalid."); } var result = UtilProcess.StartProcessGetString(VmrunInstallFullPath, $"snapshot \"{_vmxFullPath}\" \"{takeSnapshotName}\""); if (!result.Equals("")) { throw new Exception(result); } } catch (Exception ex) { Logger.LogThrowMessage($"Failed to take Snapshot [{takeSnapshotName}] of VM [{_vmxFullPath}].", new StackFrame(0).GetMethod().Name, ex.Message); } }
public void ConnectShare(bool isPersistent = true) { var persistentValue = "YES"; if (!isPersistent) { persistentValue = "NO"; } var para = $@"use {ShareFolderFullPath} {(UserName.Equals("") ? "" : "/User:"******"; try { UtilProcess.StartProcessGetString("net", para); } catch (Exception) { //Logger.LogThrowMessage(string.Format(@"Failed to execute [net {0}]", para), new StackFrame(0).GetMethod().Name, ex.Message); throw new Exception($@"Failed to execute [net {para}]"); } }
public bool IsSnapshotExisting(string snapshotName) { try { var snapshots = UtilProcess.StartProcessGetStrings(VmrunInstallFullPath, $"listSnapshots \"{_vmxFullPath}\""); //foreach (var snapshot in snapshots) //{ // if (snapshot.Equals(snapshotName)) // { // return true; // } //} //return false; return(snapshots.Any(snapshot => snapshot.Equals(snapshotName))); } catch (Exception ex) { Logger.LogThrowMessage($"Failed to find Snapshot [{_vmxFullPath}] from VM [{snapshotName}].", new StackFrame(0).GetMethod().Name, ex.Message); return(false); } }