/// <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); if (Host.Local.TryFindSingle <Ranorex.Button>(xPathCheckout, 2000, out btnCheckout)) { Report.Log(ReportLevel.Info, "Mouse", "Clicking Checkout"); btnCheckout.Click(); } Global.CriteriaType = "Exit"; Global.Proceed = false; TestModuleRunner.Run(V); TestReport.EndTestModule(); if (!Global.Proceed) { TestReport.EndTestCase(TestResult.Failed); } }
/// <summary> /// The finish reporting. /// </summary> /// <param name="executionObject"> /// The execution object. /// </param> /// <param name="testCaseInfo"> /// The test Case Info. /// </param> public static void FinishReporting(ref ExecutionObject executionObject, ref TestCaseInfo testCaseInfo) { Log.Enter(LogInfo.Namespace(MethodBase.GetCurrentMethod()), MethodBase.GetCurrentMethod().Name); try { testCaseInfo.TestCaseName = currentTestCase; // executionObject.TestCaseName; testCaseInfo.TestCasePath = executionObject.ReportFolderTestCases; testCaseInfo.TestCaseResult = (TestResult)TestReport.CurrentTestModuleActivity.Status; executionObject.CurrentTestReportInfo.TestCaseInfos.Add(testCaseInfo); // Finish testcase logfile TestReport.EndTestModule(); TestReport.SetCurrentTestResult(testCaseInfo.TestCaseResult); TestReport.EndTestCase(); TestReport.SetCurrentTestResult(testCaseInfo.TestCaseResult); TestReport.EndTestCaseSetup(); TestReport.SetCurrentTestResult(testCaseInfo.TestCaseResult); TestReport.SaveReport(); TestReport.Clear(); } catch (Exception exception) { Log.Enter(LogInfo.Namespace(MethodBase.GetCurrentMethod()), exception.Message); } }
/// <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 Select = Global.xelModule.Attribute("Select").Value; switch (Select) { case "Basic": break; case "Pro": break; case "Not Intrested": if (Host.Local.TryFindSingle <Ranorex.Text>(xPathNotIntrested, 2000, out txtPURSelection)) { Report.Log(ReportLevel.Info, "Mouse", "Clicking Not intrested"); txtPURSelection.Click(); } break; case "Renew": break; default: break; } 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 GPGSelect = Global.xelModule.Attribute("Select").Value; if (GPGSelect.ToLower() == "all") { if (Host.Local.TryFindSingle <Ranorex.Button>(xPathAddGPGAll, 2000, out btnAddGPGAll)) { Report.Log(ReportLevel.Info, "Mouse", "Clicking Add GPG to all items button"); btnAddGPGAll.Click(); } } if (Host.Local.TryFindSingle <Ranorex.Button>(xPathGPGContinue, 2000, out btnGPGContinue)) { Report.Log(ReportLevel.Info, "Mouse", "Clicking C ontinueAdd GPG to all items button"); btnGPGContinue.Click(); } if (!Global.Proceed) { TestReport.EndTestModule(); } Global.CriteriaType = "Exit"; Global.Proceed = false; TestModuleRunner.Run(V); TestReport.EndTestModule(); if (!Global.Proceed) { TestReport.EndTestCase(TestResult.Failed); } }
/* * Path with 2 blocks/modules, successful */ public TestResult Path1Usermethod() { TestReport.BeginTestCase("Flow1_Path1"); TestResult testResult = TestResult.Skipped; try { TestReport.BeginTestModule("Flow1_Path1_Block1"); // --- BEGIN ARD Blockcode --- Report.Info("Flow1 Path Block1"); // --- END ARD Blockcode --- TestReport.EndTestModule(); TestReport.BeginTestModule("Flow1_Path1_Block2"); // --- BEGIN ARD Blockcode --- Report.Info("Flow1 Path Block2"); // --- END ARD Blockcode --- TestReport.EndTestModule(); testResult = TestResult.Passed; } catch (Exception e) { TestReport.EndTestModule(); testResult = RanorexCoreReflectionHelper.HandleError(e); TestReport.SaveLocalScreenshotBuffer(); } finally { TestReport.BeginTestCaseTeardown(); try { TestReport.BeginTestModule("Flow1_Path2_Teardown"); // --- BEGIN ARD Blockcode --- Report.Info("There goes the successful Teardown"); // --- END ARD Blockcode --- TestReport.EndTestModule(); } catch (Exception e) { TestReport.EndTestModule(); testResult = RanorexCoreReflectionHelper.HandleError(e); TestReport.SaveLocalScreenshotBuffer(); } finally { TestReport.EndTestCaseTeardown(); TestReport.EndTestCase(); } } return(testResult); }
/// <summary> /// The finish execution. /// </summary> /// <param name="testResult"> /// The test Result. /// </param> public static void FinishReporting(TestResult testResult) { Log.Enter(LogInfo.Namespace(MethodBase.GetCurrentMethod()), MethodBase.GetCurrentMethod().Name); // Finish testcase logfile TestReport.EndTestModule(); TestReport.SetCurrentTestResult(testResult); TestReport.EndTestCase(); TestReport.SetCurrentTestResult(testResult); TestReport.EndTestCaseSetup(); TestReport.SetCurrentTestResult(testResult); TestReport.SaveReport(); TestReport.Clear(); }
/// <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); bool AddCustomer = Convert.ToBoolean(Global.xelModule.Attribute("AddCustomer").Value); if (!AddCustomer) { if (Host.Local.TryFindSingle <Ranorex.Button>(xPathDoNotInclude, 2000, out btnDoNotInclude)) { Report.Log(ReportLevel.Info, "Mouse", "Clicking Do Not Include"); btnDoNotInclude.Click(); } } else { if (Host.Local.TryFindSingle <Ranorex.Text>(xPathFindCustomer, 2000, out txtFindCustomer)) { txtFindCustomer.Click(); FindCustomer mFindCustomer = new FindCustomer(); TestModuleRunner.Run(mFindCustomer); } } Global.CriteriaType = "Exit"; Global.Proceed = false; TestModuleRunner.Run(V); TestReport.EndTestModule(); if (!Global.Proceed) { TestReport.EndTestCase(TestResult.Failed); } }
/* * Path with 1 block/module, fails in the block/module itself */ public TestResult Path1Usermethod() { TestReport.BeginTestCase("Flow2_Path1"); TestResult testResult = TestResult.Skipped; try { TestReport.BeginTestModule("Flow2_Path1_Block1"); // --- BEGIN ARD Blockcode --- Report.Info("Flow2 Path Block1"); Validate.IsTrue(false); // --- END ARD Blockcode --- TestReport.EndTestModule(); testResult = TestResult.Passed; } catch (Exception e) { TestReport.EndTestModule(); testResult = RanorexCoreReflectionHelper.HandleError(e); TestReport.SaveLocalScreenshotBuffer(); } finally { TestReport.BeginTestCaseTeardown(); try { TestReport.BeginTestModule("Flow2_Path1_Teardown"); // --- BEGIN ARD Blockcode --- Report.Info("And our teardown does its job"); Validate.IsTrue(true); // --- END ARD Blockcode --- TestReport.EndTestModule(); } catch (Exception e) { TestReport.EndTestModule(); testResult = RanorexCoreReflectionHelper.HandleError(e); TestReport.SaveLocalScreenshotBuffer(); } finally { TestReport.EndTestCaseTeardown(); TestReport.EndTestCase(); } } return(testResult); }
public void ExecuteScenarios() { var rnd = new Random(); //Loop through the scenario list while the list still has scenarios while (lsScenarios.Count != 0) { var index = rnd.Next(0, lsScenarios.Count); string strScenarioId = lsScenarios[index]; XDocument xdocSc = XDocument.Load(@"c:\PAL\Automation\Scenarios\" + strScenarioId + ".config"); TestReport.BeginTestCase("Scenario " + strScenarioId, ""); Report.Log(ReportLevel.Info, "Scenario", "Starting Scenario " + strScenarioId); //Query xml for the scenario matching the random selected scenario index var lv1s = from lv1 in xdocSc.Descendants("module") select lv1; //Loop through results foreach (var lv1 in lv1s) { if (Global.Proceed) { Global.xelModule = lv1; switch (lv1.Attribute("name").Value) { case "login": Login mLogin = new Login(); TestModuleRunner.Run(mLogin); break; case "AddItems": AddItems mAddItems = new AddItems(); TestModuleRunner.Run(mAddItems); break; case "GPG": GPG mGPG = new GPG(); TestModuleRunner.Run(mGPG); break; case "IncludeCustomer": IncludeCustomer mIncludeCustomer = new IncludeCustomer(); TestModuleRunner.Run(mIncludeCustomer); break; case "PURBenefits": PURBenefits mPURBenefits = new PURBenefits(); TestModuleRunner.Run(mPURBenefits); break; case "Checkout": Checkout mCheckout = new Checkout(); TestModuleRunner.Run(mCheckout); break; case "Cash": Cash mCash = new Cash(); TestModuleRunner.Run(mCash); break; default: break; } } } lsScenarios.RemoveAt(index); TestReport.EndTestCase(); Global.Proceed = true; } }
/// <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); } }
/* * Path with 1 block/module, automates notepad and then fails in the teardown */ public TestResult Path2Usermethod() { TestReport.BeginTestCase("Flow1_Path2"); TestResult testResult = TestResult.Skipped; try { TestReport.BeginTestModule("Flow1_Path2_Block1"); // --- BEGIN ARD Blockcode --- Report.Info("Flow1 Path2 Block1 (only block)"); Report.Info("This is it!"); Delay.Milliseconds(200); Report.Info("This is it!"); Delay.Milliseconds(200); var start = repo.Explorer.Start; start.MoveTo(); // copied from NotepadTest Report.Log(ReportLevel.Info, "Application", "Run application 'C:\\Windows\\System32\\notepad.exe' with arguments '' in normal mode."); Host.Local.RunApplication("C:\\Windows\\System32\\notepad.exe", "", "C:\\Windows\\System32", false); Report.Log(ReportLevel.Info, "Mouse", "Mouse Left Click item 'UntitledNotepad.Text15' at 254;96.", repo.UntitledNotepad.Text15Info); repo.UntitledNotepad.Text15.Click("254;96"); Report.Log(ReportLevel.Info, "Keyboard", "Key sequence 'aaa' with focus on 'UntitledNotepad.Text15'.", repo.UntitledNotepad.Text15Info); repo.UntitledNotepad.Text15.PressKeys("aaa"); Report.Log(ReportLevel.Info, "Mouse", "Mouse Left Click item 'UntitledNotepad.Edit' at 21;17.", repo.UntitledNotepad.EditInfo); repo.UntitledNotepad.Edit.Click("21;17"); Report.Log(ReportLevel.Info, "Mouse", "Mouse Left Click item 'Notepad.UndoCtrlPlusZ' at 35;6.", repo.Notepad.UndoCtrlPlusZInfo); repo.Notepad.UndoCtrlPlusZ.Click("35;6"); Report.Log(ReportLevel.Info, "Mouse", "Mouse Left Click item 'UntitledNotepad.File' at 5;14.", repo.UntitledNotepad.FileInfo); repo.UntitledNotepad.File.Click("5;14"); Report.Log(ReportLevel.Info, "Mouse", "Mouse Left Click item 'Notepad.Exit' at 34;13.", repo.Notepad.ExitInfo); repo.Notepad.Exit.Click("34;13"); // --- END ARD Blockcode --- TestReport.EndTestModule(); testResult = TestResult.Passed; } catch (Exception e) { TestReport.EndTestModule(); testResult = RanorexCoreReflectionHelper.HandleError(e); TestReport.SaveLocalScreenshotBuffer(); } finally { TestReport.BeginTestCaseTeardown(); try { TestReport.BeginTestModule("Flow1_Path2_Teardown"); // --- BEGIN ARD Blockcode --- Report.Info("And our teardown blows off"); Validate.IsTrue(false); // --- END ARD Blockcode --- TestReport.EndTestModule(); } catch (Exception e) { TestReport.EndTestModule(); testResult = RanorexCoreReflectionHelper.HandleError(e); TestReport.SaveLocalScreenshotBuffer(); } finally { TestReport.EndTestCaseTeardown(); TestReport.EndTestCase(); } } return(testResult); }
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; 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); } }
/// <summary> /// Ends the test case. /// </summary> public static void EndTestCase() { TestReport.EndTestCase(); }