/* * 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); }
/* * 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); }
/* * 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); }