public static string RestartSystemX(bool autoLogin = true) { string response = "Det oppsto kritisk feil på den foregående test. Starte System X program"; try { // Kill System X process Process systemxProcess = Process.GetProcessesByName("Systemx")[0]; systemxProcess.Kill(); Delay.Seconds(2); KillCrashProgram(); try { // Get the System X path and run it string appName = File.ReadAllText(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\SystemxPath.log"); Process.Start(appName); // If System X is not properly terminated, this window will popup try { Ranorex.Form frmProgFail = Host.Local.FindSingle <Ranorex.Form>("/form[@title='Bekreft']", 5000); frmProgFail.PressKeys("{ESCAPE}"); } catch (ElementNotFoundException) { // Do nothing } if (autoLogin) { try { // Get login details string[] details = File.ReadAllText(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\login.log").Split(';'); string username = details[0]; string password = details[1]; try { Ranorex.Text txtUsername = Host.Local.FindSingle <Ranorex.Text>("/form[@controlname='FPassord']/text[@controlname='UsrName']", 2000); Ranorex.Text txtPassword = Host.Local.FindSingle <Ranorex.Text>("/form[@controlname='FPassord']/text[@controlname='PWord']", 2000); txtUsername.Focus(); txtUsername.PressKeys(username); txtPassword.Focus(); txtPassword.PressKeys(password); Ranorex.Form frmCalendar = Host.Local.FindSingle <Ranorex.Form>("/form[@controlname='fdt']", 3000); frmCalendar.Activate(); frmCalendar.PressKeys("{ENTER}"); Delay.Seconds(2); } catch (ElementNotFoundException) { //Do nothing } } catch (FileNotFoundException) { response = "Kan ikke logge inn automatisk. Finner ikke loggfilen som inneholder de siste innloggingsdetaljer"; } } } catch (FileNotFoundException) { response = "Kan ikke starte System X. Loggfilen som inneholder mangler System X stien"; } } catch (IndexOutOfRangeException) { response = "Kan ikke avslutte System X prosess. Kan ikke finne prosessnavnet"; } return(response); }
void ITestModule.Run() { Mouse.DefaultMoveTime = 100; Keyboard.DefaultKeyPressTime = 100; Delay.SpeedFactor = 1.0; TestReport.BeginTestModule(this.GetType().Name); Global.xdocModule = XDocument.Load(@"C:\PAL\Automation\Modules\" + this.GetType().Name + ".config"); Global.CriteriaType = "Entrance"; Global.Proceed = false; Verify V = new Verify(); TestModuleRunner.Run(V); if (!Global.Proceed) { TestReport.EndTestModule(); } string strUsername = ""; string strPassword = ""; try { strUsername = Global.xelModule.Attribute("username").Value; strPassword = Global.xelModule.Attribute("password").Value; } catch {} //string strRegisterIni = "c:\\pos\\register.ini"; IniFile iniRegister = new IniFile(Global.strRegisterIni); string strStatus = iniRegister.IniReadValue("Terminal", "Status"); strStatus = strStatus.ToLower(); Global.stwStepStopWatch = new Stopwatch(); Global.stwIterationStopWatch = new Stopwatch(); //Start the time Global.stwStepStopWatch.Start(); Global.stwIterationStopWatch.Start(); if (strStatus == "open") { if (!Host.Local.TryFindSingle <Ranorex.Text>(xPathTxtUserID, 100, out txtUserId)) { Host.Local.TryFindSingle <Ranorex.Button>(xPathPressF5ToStartANewTransaction, 2000, out btnNewTransaction); Report.Log(ReportLevel.Info, "Mouse", "Click on 'PressF5ToStartANewTransaction'."); btnNewTransaction.Click(); } } if (Host.Local.TryFindSingle <Ranorex.Text>(xPathTxtUserID, 2000, out txtUserId)) { Report.Log(ReportLevel.Info, "Keyboard", "Key sequence 'psu' with focus on 'TxtUserId'."); txtUserId.PressKeys(strUsername); } if (Host.Local.TryFindSingle <Ranorex.Text>(xPathTxtPassword, 2000, out txtPassword)) { Report.Log(ReportLevel.Info, "Keyboard", "Key sequence 'advanced' with focus on 'TxtPassword'."); txtPassword.PressKeys(strPassword); Report.Log(ReportLevel.Info, "Keyboard", "Key sequence '{Return}' with focus on 'TxtPassword'."); txtPassword.PressKeys("{Return}"); } Global.CriteriaType = "Exit"; Global.Proceed = false; TestModuleRunner.Run(V); Global.stwStepStopWatch.Stop(); Global.logger.Add(1, Global.intIteration, Global.strID, this.GetType().Name, Global.stwStepStopWatch.Elapsed); if (Global.Proceed) { TestReport.EndTestModule(); } if (!Global.Proceed) { TestReport.EndTestCase(TestResult.Failed); } }
/// <summary> /// Performs the playback of actions in this module. /// </summary> /// <remarks>You should not call this method directly, instead pass the module /// instance to the <see cref="TestModuleRunner.Run(ITestModule)"/> method /// that will in turn invoke this method.</remarks> void ITestModule.Run() { Mouse.DefaultMoveTime = 300; Keyboard.DefaultKeyPressTime = 100; Delay.SpeedFactor = 1.0; string SKU = ""; string DEPT = ""; string ESRB = ""; int QTY = 0; bool GPG; TestReport.BeginTestModule(this.GetType().Name); Global.xdocModule = XDocument.Load(@"C:\PAL\Automation\Modules\" + this.GetType().Name + ".config"); Global.CriteriaType = "Entrance"; Global.Proceed = false; Verify V = new Verify(); TestModuleRunner.Run(V); if (!Global.Proceed) { TestReport.EndTestModule(); } try { SKU = Global.xelModule.Attribute("SKU").Value; } catch {} try { DEPT = Global.xelModule.Attribute("DEPT").Value; } catch {} try { ESRB = Global.xelModule.Attribute("ESRB").Value; } catch {} try { QTY = Convert.ToInt32(Global.xelModule.Attribute("QTY").Value); } catch {} try { GPG = Convert.ToBoolean(Global.xelModule.Attribute("QTY").Value); } catch {} for (int i = 0; i < QTY; i++) { if (Host.Local.TryFindSingle <Ranorex.Button>(xPathPurchase, 2000, out btnPurchase)) { Report.Log(ReportLevel.Info, "Mouse", "Click on 'Purchases'."); btnPurchase.Click(); if (Host.Local.TryFindSingle <Ranorex.Text>(xpathAddItem, 2000, out txtAddItem)) { Report.Log(ReportLevel.Info, "Keyboard", "Enter SKU followed by the Enter key."); txtAddItem.PressKeys(SKU + "{Return}"); Delay.Milliseconds(1000); } } } Global.CriteriaType = "Exit"; Global.Proceed = false; TestModuleRunner.Run(V); TestReport.EndTestModule(); if (!Global.Proceed) { TestReport.EndTestCase(TestResult.Failed); } }
/// <summary> /// Performs the playback of actions in this module. /// </summary> /// <remarks>You should not call this method directly, instead pass the module /// instance to the <see cref="TestModuleRunner.Run(ITestModule)"/> method /// that will in turn invoke this method.</remarks> void ITestModule.Run() { Mouse.DefaultMoveTime = 300; Keyboard.DefaultKeyPressTime = 100; Delay.SpeedFactor = 1.0; TestReport.BeginTestModule(this.GetType().Name); Global.xdocModule = XDocument.Load(@"C:\PAL\Automation\Modules\" + this.GetType().Name + ".config"); Global.CriteriaType = "Entrance"; Global.Proceed = false; Verify V = new Verify(); TestModuleRunner.Run(V); string TenderAmount = ""; string BalanceDue = ""; string Tender = Global.xelModule.Attribute("Tender").Value; if (Host.Local.TryFindSingle <Ranorex.Text>(xPathBalanceDue, 2000, out txtBalanceDue)) { BalanceDue = txtBalanceDue.TextValue.Replace("$", ""); } if (Host.Local.TryFindSingle <Ranorex.Text>(xPathCash, 2000, out txtCash)) { Report.Log(ReportLevel.Info, "Mouse", "Clicking Cash"); txtCash.Click(); } if (Host.Local.TryFindSingle <Ranorex.Text>(xPathAmountPaid, 2000, out txtAmountPaid)) { switch (Tender) { case "Exact": TenderAmount = BalanceDue; break; case "Split w/ Credit Prompt": break; case "Split": break; case "Over": break; default: break; } Report.Log(ReportLevel.Info, "Keyboard", "Typing " + TenderAmount + " and a Return in AmountPaid"); txtAmountPaid.PressKeys(TenderAmount + "{Return}"); } Validate.Exists(xPathChangeDue, 5000, "Change Due Prompt Displayed", false); GamestopAutomationRepository repo = GamestopAutomationRepository.Instance; RepoItemInfo ChangeDueInfo = new RepoItemInfo(repo, "ChangeDue", xPathChangeDue, 30000, null); ChangeDueInfo.WaitForNotExists(30000); //Validate.NotExists(xPathChangeDue,10000,"Change Due Prompt Closed",false); Global.CriteriaType = "Exit"; Global.Proceed = false; TestModuleRunner.Run(V); TestReport.EndTestModule(); if (!Global.Proceed) { TestReport.EndTestCase(TestResult.Failed); } }